Merge branch 'wcd' of http://192.168.1.110:5678/r/pms-upgrade into wcd
18 files added
38 files modified
| | |
| | | public enum CompanySuffix { |
| | | COMPANY_1("以恒(大连)企业管理有限公司", "YHQG"), |
| | | COMPANY_2("大连以恒科技有限公司", "YHKJ"), |
| | | COMPANY_3("恒春科技(大连)有限公司", "HCKJ"), |
| | | COMPANY_3("恒春科技(大连)有限责任公司", "HCKJ"), |
| | | COMPANY_4("恒臻科技(大连)有限责任公司", "HZKJ"), |
| | | COMPANY_5("兴安盟恒新知识产权服务有限公司", "XAHX"), |
| | | COMPANY_6("兴安盟以恒科技有限公司", "XAYH"), |
| | |
| | | <!-- <version>4.7.2.B</version>-->
|
| | | <version>4.7.7-20250915.094526</version>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>redis.clients</groupId>
|
| | | <artifactId>jedis</artifactId>
|
| | | <version>3.3.0</version>
|
| | | </dependency>
|
| | |
|
| | | <!-- 模拟前端渲染 -->
|
| | | <dependency>
|
| | |
| | | package me.zhengjie.config; |
| | | |
| | | import com.binarywang.spring.starter.wxjava.cp.properties.WxCpProperties; |
| | | import com.binarywang.spring.starter.wxjava.cp.properties.WxCpRedisProperties; |
| | | import me.chanjar.weixin.cp.api.WxCpService; |
| | | import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; |
| | | import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; |
| | | import me.chanjar.weixin.cp.config.impl.WxCpJedisConfigImpl; |
| | | import me.chanjar.weixin.cp.config.impl.WxCpRedisTemplateConfigImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import redis.clients.jedis.JedisPool; |
| | | import redis.clients.jedis.JedisPoolConfig; |
| | | |
| | | /** |
| | | * @author baoLh |
| | |
| | | |
| | | @Bean |
| | | public WxCpService wxCpService() { |
| | | // // 默认缓存配置 |
| | | // WxCpDefaultConfigImpl configStorage = new WxCpDefaultConfigImpl(); |
| | | |
| | | WxCpDefaultConfigImpl configStorage; |
| | | if (wxCpProperties.getConfigStorage().getType().equals(WxCpProperties.StorageType.redistemplate)) { |
| | | // redis缓存配置 |
| | | StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class); |
| | | WxCpDefaultConfigImpl configStorage = new WxCpRedisTemplateConfigImpl(redisTemplate, wxCpProperties.getConfigStorage().getKeyPrefix()); |
| | | configStorage = new WxCpRedisTemplateConfigImpl(redisTemplate, wxCpProperties.getConfigStorage().getKeyPrefix()); |
| | | } else if (wxCpProperties.getConfigStorage().getType().equals(WxCpProperties.StorageType.jedis)) { |
| | | // jedis配置 |
| | | WxCpRedisProperties wxCpRedisProperties = wxCpProperties.getConfigStorage().getRedis(); |
| | | JedisPool jedisPool; |
| | | if (wxCpRedisProperties != null && StringUtils.isNotEmpty(wxCpRedisProperties.getHost())) { |
| | | jedisPool = getJedisPool(); |
| | | } else { |
| | | jedisPool = applicationContext.getBean(JedisPool.class); |
| | | } |
| | | configStorage = new WxCpJedisConfigImpl(jedisPool, wxCpProperties.getConfigStorage().getKeyPrefix()); |
| | | } else { |
| | | // 默认缓存配置 |
| | | configStorage = new WxCpDefaultConfigImpl(); |
| | | } |
| | | |
| | | // 基本配置 |
| | | configStorage.setCorpId(wxCpProperties.getCorpId()); |
| | | configStorage.setAgentId(wxCpProperties.getAgentId()); |
| | | configStorage.setCorpSecret(wxCpProperties.getCorpSecret()); |
| | |
| | | |
| | | return wxCpService; |
| | | } |
| | | |
| | | private JedisPool getJedisPool() { |
| | | WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); |
| | | WxCpRedisProperties redis = storage.getRedis(); |
| | | |
| | | JedisPoolConfig config = new JedisPoolConfig(); |
| | | if (redis.getMaxActive() != null) { |
| | | config.setMaxTotal(redis.getMaxActive()); |
| | | } |
| | | if (redis.getMaxIdle() != null) { |
| | | config.setMaxIdle(redis.getMaxIdle()); |
| | | } |
| | | if (redis.getMaxWaitMillis() != null) { |
| | | config.setMaxWaitMillis(redis.getMaxWaitMillis()); |
| | | } |
| | | if (redis.getMinIdle() != null) { |
| | | config.setMinIdle(redis.getMinIdle()); |
| | | } |
| | | config.setTestOnBorrow(true); |
| | | config.setTestWhileIdle(true); |
| | | |
| | | return new JedisPool(config, redis.getHost(), redis.getPort(), |
| | | redis.getTimeout(), redis.getPassword(), redis.getDatabase()); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty(value = "企微关联项目名称")
|
| | | private String wecomProjectName;
|
| | |
|
| | | @Column(name = "`wecom_category_name`")
|
| | | @ApiModelProperty(value = "企微出差类别名称")
|
| | | private String wecomCategoryName;
|
| | |
|
| | | public void copy(AttendanceBusinessTravel source){
|
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
| | | }
|
| | |
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.NotNull;
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | | import java.sql.Timestamp;
|
| | |
|
| | | /**
|
| | |
| | | @ApiModelProperty(value = "备注")
|
| | | private String remarks;
|
| | |
|
| | | @Column(name = "`remaining_duration`")
|
| | | @ApiModelProperty(value = "调休可用时长")
|
| | | private Double remainingDuration;
|
| | |
|
| | | @Column(name = "`wecom_sp_no`")
|
| | | @ApiModelProperty(value = "企微审批单号")
|
| | | private String wecomSpNo;
|
| | |
| | | public void copy(AttendanceOvertime source){
|
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 扣减额度
|
| | | * @param amount / 扣除数额
|
| | | * @return 剩余待扣除数额
|
| | | */
|
| | | public double subtractDuration(double amount) {
|
| | | BigDecimal amountBigDecimal = new BigDecimal(amount);
|
| | | BigDecimal remainingBigDecimal = new BigDecimal(this.remainingDuration);
|
| | | BigDecimal subtractBigDecimal = remainingBigDecimal.subtract(amountBigDecimal);
|
| | | this.remainingDuration = subtractBigDecimal.max(BigDecimal.ZERO).doubleValue();
|
| | | return subtractBigDecimal.compareTo(BigDecimal.ZERO) > 0 ? BigDecimal.ZERO.doubleValue() : subtractBigDecimal.abs().doubleValue();
|
| | | }
|
| | | }
|
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.Table; |
| | | import org.hibernate.annotations.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="overtime_consumed_record") |
| | | public class OvertimeConsumedRecord implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`leave_id`") |
| | | @ApiModelProperty(value = "请假单关联ID") |
| | | private Long leaveId; |
| | | |
| | | @Column(name = "`overtime_id`") |
| | | @ApiModelProperty(value = "调休单关联ID") |
| | | private Long overtimeId; |
| | | |
| | | @Column(name = "`user_id`") |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | @Column(name = "`consumed_duration`") |
| | | @ApiModelProperty(value = "消耗工时") |
| | | private Double consumedDuration; |
| | | |
| | | @Column(name = "`create_time`") |
| | | @CreationTimestamp |
| | | @ApiModelProperty(value = "创建时间") |
| | | private Timestamp createTime; |
| | | |
| | | public void copy(OvertimeConsumedRecord source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| | |
| | | package me.zhengjie.modules.attendance.repository; |
| | | |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | |
| | | import me.zhengjie.modules.attendance.domain.AttendanceOvertime;
|
| | | import org.springframework.data.jpa.repository.JpaRepository;
|
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
| | | import org.springframework.data.jpa.repository.Modifying;
|
| | | import org.springframework.data.jpa.repository.Query;
|
| | |
|
| | | import java.time.LocalDateTime;
|
| | |
| | | List<AttendanceOvertime> findByUserId(Long userId);
|
| | |
|
| | | List<AttendanceOvertime> findByUserIdAndApprovalStatus(Long userId, String overtimePass);
|
| | |
|
| | | @Modifying
|
| | | @Query(value = "UPDATE attendance_overtime SET remaining_duration = overtime_duration WHERE user_id = ?1", nativeQuery = true)
|
| | | void resetRemainingDuration(Long userId);
|
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.repository; |
| | | |
| | | import me.zhengjie.modules.attendance.domain.OvertimeConsumedRecord; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | public interface OvertimeConsumedRecordRepository extends JpaRepository<OvertimeConsumedRecord, Long>, JpaSpecificationExecutor<OvertimeConsumedRecord> { |
| | | |
| | | @Query |
| | | int deleteAllByUserId(Long userId); |
| | | } |
| | |
| | | @ApiOperation("获取调休假时长")
|
| | | public ResponseEntity<Object> getOverTimeLength(@PathVariable Long userId, @RequestBody String yearMonth) throws ParseException {
|
| | | Double overTimeLength = attendanceLeaveService.getOverTimeLength(userId, yearMonth);
|
| | | Double overTimeCloseLength = attendanceLeaveService.getOverTimeCloseLength(userId, yearMonth);
|
| | | return new ResponseEntity<>(overTimeLength + overTimeCloseLength, HttpStatus.OK);
|
| | | return new ResponseEntity<>(overTimeLength, HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PutMapping(value = "/approve")
|
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.attendance.domain.OvertimeConsumedRecord; |
| | | import me.zhengjie.modules.attendance.service.OvertimeConsumedRecordService; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "调休额度消耗记录管理") |
| | | @RequestMapping("/api/overtimeConsumedRecord") |
| | | public class OvertimeConsumedRecordController { |
| | | |
| | | private final OvertimeConsumedRecordService overtimeConsumedRecordService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('overtimeConsumedRecord:list')") |
| | | public void exportOvertimeConsumedRecord(HttpServletResponse response, OvertimeConsumedRecordQueryCriteria criteria) throws IOException { |
| | | overtimeConsumedRecordService.download(overtimeConsumedRecordService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询调休额度消耗记录") |
| | | @ApiOperation("查询调休额度消耗记录") |
| | | @PreAuthorize("@el.check('overtimeConsumedRecord:list')") |
| | | public ResponseEntity<Object> queryOvertimeConsumedRecord(OvertimeConsumedRecordQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(overtimeConsumedRecordService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增调休额度消耗记录") |
| | | @ApiOperation("新增调休额度消耗记录") |
| | | @PreAuthorize("@el.check('overtimeConsumedRecord:add')") |
| | | public ResponseEntity<Object> createOvertimeConsumedRecord(@Validated @RequestBody OvertimeConsumedRecord resources){ |
| | | return new ResponseEntity<>(overtimeConsumedRecordService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改调休额度消耗记录") |
| | | @ApiOperation("修改调休额度消耗记录") |
| | | @PreAuthorize("@el.check('overtimeConsumedRecord:edit')") |
| | | public ResponseEntity<Object> updateOvertimeConsumedRecord(@Validated @RequestBody OvertimeConsumedRecord resources){ |
| | | overtimeConsumedRecordService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除调休额度消耗记录") |
| | | @ApiOperation("删除调休额度消耗记录") |
| | | @PreAuthorize("@el.check('overtimeConsumedRecord:del')") |
| | | public ResponseEntity<Object> deleteOvertimeConsumedRecord(@RequestBody Long[] ids) { |
| | | overtimeConsumedRecordService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/allConsumedDeduction") |
| | | @Log("整理全部调休扣除") |
| | | @ApiOperation("整理全部调休扣除") |
| | | public ResponseEntity<Object> allConsumedDeduction(){ |
| | | overtimeConsumedRecordService.allConsumedDeduction(); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | import org.springframework.data.domain.Pageable;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.time.LocalDateTime;
|
| | | import java.util.Map;
|
| | | import java.util.List;
|
| | | import java.io.IOException;
|
| | |
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | Double getOverTimeLength(Long userId) throws ParseException;
|
| | | Double getOverTimeLength(Long userId, LocalDateTime localDateTime) throws ParseException;
|
| | |
|
| | | Double getOverTimeLength(Long userId, String yearMonth) throws ParseException;
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId);
|
| | | Double getOverTimeCloseLength(Long userId, LocalDateTime localDateTime);
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId, String yearMonth);
|
| | | Double getOverTimeCurrentCloseLength(Long userId, LocalDateTime localDateTime);
|
| | |
|
| | | /**
|
| | | * 审核功能
|
| | |
| | |
|
| | | Double queryAttendanceHolidaysOverTimeHours(AttendanceQueryCriteria criteria);
|
| | |
|
| | | Double queryAttendanceWeekendOverTimeHours(AttendanceQueryCriteria criteria);
|
| | |
|
| | | /**
|
| | | * 查询某月平日加班小时数
|
| | | * @param criteria 条件参数
|
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service; |
| | | |
| | | import me.zhengjie.modules.attendance.domain.OvertimeConsumedRecord; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordDto; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | public interface OvertimeConsumedRecordService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(OvertimeConsumedRecordQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<OvertimeConsumedRecordDto> |
| | | */ |
| | | List<OvertimeConsumedRecordDto> queryAll(OvertimeConsumedRecordQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return OvertimeConsumedRecordDto |
| | | */ |
| | | OvertimeConsumedRecordDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return OvertimeConsumedRecordDto |
| | | */ |
| | | OvertimeConsumedRecordDto create(OvertimeConsumedRecord resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(OvertimeConsumedRecord resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<OvertimeConsumedRecordDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | /** |
| | | * 整理全部调休扣除 |
| | | */ |
| | | void allConsumedDeduction(); |
| | | } |
| | |
| | | @Query |
| | | private String approvalStatus; |
| | | |
| | | @Query(type = Query.Type.IN, propName = "approvalStatus") |
| | | private List<String> approvalStatusList; |
| | | |
| | | @Query(type = Query.Type.BETWEEN, propName = "leaveStartTime") |
| | | private List<Timestamp> leaveStartTime; |
| | | |
| | |
| | | private List<Long> userIds;
|
| | |
|
| | | private String targetYearMonth;
|
| | |
|
| | | @Query(propName = "dateType", type = Query.Type.EQUAL)
|
| | | private String dateType;
|
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @Data |
| | | public class OvertimeConsumedRecordDto implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 请假单关联ID */ |
| | | private Long leaveId; |
| | | |
| | | /** 调休单关联ID */ |
| | | private Long overtimeId; |
| | | |
| | | /** 用户ID */ |
| | | private Long userId; |
| | | |
| | | /** 消耗工时 */ |
| | | private Double consumedDuration; |
| | | |
| | | /** 创建时间 */ |
| | | private Timestamp createTime; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @Data |
| | | public class OvertimeConsumedRecordQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long leaveId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long overtimeId; |
| | | /** BETWEEN */ |
| | | @Query(type = Query.Type.BETWEEN) |
| | | private List<Timestamp> createTime; |
| | | } |
| | |
| | | // 判断是否提交企微审批 |
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList()); |
| | | if (siteTypes.size() > 0) { |
| | | Map<String, String> categoryNameMap = dictDetailRepository.findByDictName(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); |
| | | // 添加企微申请参数 |
| | | attendanceBusinessTravel.setWecomProjectName(project.getName()); |
| | | attendanceBusinessTravel.setWecomCategoryName(categoryNameMap.get(resources.getCategory())); |
| | | attendanceBusinessTravel.setWecomLocation(String.format("%s -至- %s", Optional.ofNullable(attendanceBusinessTravel.getDepartureCity()).orElse("出发城市"), Optional.ofNullable(attendanceBusinessTravel.getArrivalCity()).orElse("到达城市"))); |
| | | attendanceBusinessTravel.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HALFDAY); |
| | | attendanceBusinessTravel.setWecomDuration(String.valueOf(new BigDecimal(attendanceBusinessTravel.getTravelDuration()).multiply(new BigDecimal(86400)).longValue())); |
| | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | Map<String, String> bussDurationUnitMap = dictDetailRepository.findByDictName(Constant.LEAVE_TIME_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); |
| | | Map<String, String> bussStatusMap = dictDetailRepository.findByDictName(Constant.BUSSINESS_APPROVE_STATUS).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); |
| | | Map<String, String> bussCategoryMap = dictDetailRepository.findByDictName(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); |
| | | for (AttendanceBusinessTravelDto attendanceBusinessTravel : all) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户", attendanceBusinessTravel.getUserName()); |
| | |
| | | map.put("出差原因", attendanceBusinessTravel.getTravelReason()); |
| | | map.put("出发城市", attendanceBusinessTravel.getDepartureCity()); |
| | | map.put("到达城市", attendanceBusinessTravel.getArrivalCity()); |
| | | map.put("出差分类", attendanceBusinessTravel.getCategory() != null ? bussCategoryMap.get(attendanceBusinessTravel.getCategory()) : ""); |
| | | map.put("审批状态", attendanceBusinessTravel.getApprovalStatus() != null ? bussStatusMap.get(attendanceBusinessTravel.getApprovalStatus()) : ""); |
| | | map.put("审批说明", attendanceBusinessTravel.getApprovalDescription()); |
| | | map.put("备注", attendanceBusinessTravel.getRemarks()); |
| | |
| | | LocalTime startTime = resources.getOutStartTime().toLocalDateTime().toLocalTime();
|
| | | LocalTime endTime = resources.getOutEndTime().toLocalDateTime().toLocalTime();
|
| | | long distance = ChronoUnit.DAYS.between(startDate, endDate);
|
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
|
| | | Stream.iterate(startDate, d -> d.plusDays(1)).limit(distance + 1).forEach(localDate -> {
|
| | | // SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | | // Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
|
| | |
| | | if (resources.getUserId() == null) {
|
| | | resources.setUserId(user.getId());
|
| | | }
|
| | | resources.setOutStartTime(Timestamp.valueOf(localDate.atTime(startTime)));
|
| | | resources.setOutEndTime(Timestamp.valueOf(localDate.atTime(endTime)));
|
| | |
|
| | | LocalDateTime goOutStartTime = localDate.atStartOfDay();
|
| | | LocalDateTime goOutEndTime = localDate.atTime(LocalTime.MAX);
|
| | | if (localDate.equals(endDate)) {
|
| | | goOutEndTime = localDate.atTime(endTime);
|
| | | }
|
| | | if (localDate.equals(startDate)) {
|
| | | goOutStartTime = localDate.atTime(startTime);
|
| | | }
|
| | | resources.setOutStartTime(Timestamp.valueOf(goOutStartTime));
|
| | | resources.setOutEndTime(Timestamp.valueOf(goOutEndTime));
|
| | |
|
| | | Double result = getRemainingTime(resources);
|
| | | resources.setOutDuration(result);
|
| | | resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
|
| | |
|
| | | // 判断是否提交企微审批
|
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
|
| | | if (siteTypes.size() > 0) {
|
| | | // 添加企微申请参数
|
| | | resources.setWecomType(dictDetailRepository.findByDictNameAndValue("go_out_type", resources.getOutOfOfficeType()).getLabel());
|
| | |
| | | // }
|
| | |
|
| | | // TODO:20250806修改 减去下班后休息时段
|
| | | LocalDateTime goOutStartTime = localDate.atTime(startTime);
|
| | | LocalDateTime goOutEndTime = localDate.atTime(endTime);
|
| | | LocalDateTime goOutStartTime = localDate.atStartOfDay();
|
| | | LocalDateTime goOutEndTime = localDate.atTime(LocalTime.MAX);
|
| | | if (localDate.equals(endDate)) {
|
| | | goOutEndTime = localDate.atTime(endTime);
|
| | | }
|
| | | if (localDate.equals(startDate)) {
|
| | | goOutStartTime = localDate.atTime(startTime);
|
| | | }
|
| | | LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
|
| | | LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
|
| | | LocalDateTime offStartTime = localDate.atTime(sysRostering.getWorkEndTime());
|
| | |
| | | import me.zhengjie.modules.attendance.service.AttendanceService;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria;
|
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordQueryCriteria;
|
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceLeaveMapper;
|
| | | import me.zhengjie.modules.constant.Constant;
|
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
|
| | |
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.data.domain.Page;
|
| | | import org.springframework.data.domain.Pageable;
|
| | | import org.springframework.data.domain.Sort;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
|
| | | private final AttendanceOvertimeRepository attendanceOvertimeRepository;
|
| | | private final ApproveEventRepository approveEventRepository;
|
| | | private final OvertimeConsumedRecordRepository overtimeConsumedRecordRepository;
|
| | | private final ApproveEventMapper approveEventMapper;
|
| | | private final WeComServiceImpl weComService;
|
| | | private final TemplateService templateService;
|
| | |
| | | }
|
| | |
|
| | | i++;
|
| | | attendanceLeaveRepository.save(attendanceLeave);
|
| | | AttendanceLeave attendanceLeaveSaved = attendanceLeaveRepository.save(attendanceLeave);
|
| | | if (attendanceLeaveSaved.getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)) {
|
| | | this.overtimeDeduction(attendanceLeaveSaved, false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | Long resUserId = attendanceLeave.getUserId();
|
| | | // 删除以前的记录
|
| | | for (Long id : ids) {
|
| | | AttendanceLeave delAttendanceLeave = new AttendanceLeave();
|
| | | delAttendanceLeave.setId(id);
|
| | | this.overtimeDeduction(delAttendanceLeave, true);
|
| | | attendanceLeaveRepository.deleteById(id);
|
| | | }
|
| | | // 获取当前登陆人信息,设置为请假发起人
|
| | |
| | | if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
|
| | | AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,resUserId);
|
| | | i++;
|
| | | attendanceLeaveRepository.save(attendanceLeave1);
|
| | | AttendanceLeave attendanceLeaveSaved = attendanceLeaveRepository.save(attendanceLeave1);
|
| | | if (attendanceLeaveSaved.getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)) {
|
| | | this.overtimeDeduction(attendanceLeaveSaved, false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * 获取用户调休假剩余时长
|
| | | */
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | | public Double getOverTimeLength(Long userId, LocalDateTime localDateTime) {
|
| | | LocalDateTime startLocalDateTime = localDateTime.minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | LocalDateTime endLocalDateTime = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
|
| | |
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | | // 查询可用调休申请
|
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | overtimeCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startLocalDateTime), Timestamp.valueOf(endLocalDateTime)));
|
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | overtimeCriteria.setUserId(userId);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime"));
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | return attendanceOvertimeList.stream().collect(Collectors.summingDouble(AttendanceOvertime::getRemainingDuration));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户调休假结算时长
|
| | | * 获取用户调休假剩余时长
|
| | | */
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | public Double getOverTimeLength(Long userId, String yearMonth) {
|
| | | LocalDateTime localDateTime = LocalDateTime.parse(yearMonth + "-01 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
| | | LocalDateTime startLocalDateTime = localDateTime.minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | LocalDateTime endLocalDateTime = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
|
| | |
|
| | | // 因换休3个月后会被结算,只能统计未结算的,仅当前时间3个月内(只参考月份)的可统计。
|
| | | LocalDateTime nowLocalDateTime = localDateTime.now().minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | if (nowLocalDateTime.isBefore(startLocalDateTime) || nowLocalDateTime.isAfter(endLocalDateTime)) {
|
| | | return Double.valueOf(0);
|
| | | } else {
|
| | | startLocalDateTime = nowLocalDateTime;
|
| | | }
|
| | |
|
| | | // 查询可用调休申请
|
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | overtimeCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startLocalDateTime), Timestamp.valueOf(endLocalDateTime)));
|
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | overtimeCriteria.setUserId(userId);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime"));
|
| | |
|
| | | return attendanceOvertimeList.stream().collect(Collectors.summingDouble(AttendanceOvertime::getRemainingDuration));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户待结算(下月即将结算)调休假时长
|
| | | */
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | public Double getOverTimeCloseLength(Long userId, LocalDateTime localDateTime) {
|
| | | LocalDateTime startLocalDateTime = localDateTime.minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | LocalDateTime endLocalDateTime = localDateTime.minusMonths(1L).withDayOfMonth(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
|
| | |
|
| | | // 查询可用调休申请
|
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | overtimeCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startLocalDateTime), Timestamp.valueOf(endLocalDateTime)));
|
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | overtimeCriteria.setUserId(userId);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime"));
|
| | |
|
| | | return attendanceOvertimeList.stream().collect(Collectors.summingDouble(AttendanceOvertime::getRemainingDuration));
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | |
|
| | | /**
|
| | | * 获取用户当月结算调休假时长
|
| | | */
|
| | | @Override
|
| | | public Double getOverTimeCurrentCloseLength(Long userId, LocalDateTime localDateTime) {
|
| | | LocalDateTime startLocalDateTime = localDateTime.minusMonths(3L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | LocalDateTime endLocalDateTime = localDateTime.minusMonths(2L).withDayOfMonth(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
|
| | |
|
| | | // 查询可用调休申请
|
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | overtimeCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startLocalDateTime), Timestamp.valueOf(endLocalDateTime)));
|
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | overtimeCriteria.setUserId(userId);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime"));
|
| | |
|
| | | return attendanceOvertimeList.stream().collect(Collectors.summingDouble(AttendanceOvertime::getRemainingDuration));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
|
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
|
| | | attendanceLeave.copy(resources);
|
| | | attendanceLeaveRepository.save(attendanceLeave);
|
| | | AttendanceLeave attendanceLeaveSaved = attendanceLeaveRepository.save(attendanceLeave);
|
| | | if (attendanceLeaveSaved.getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE) && attendanceLeaveSaved.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)) {
|
| | | this.overtimeDeduction(attendanceLeaveSaved, true);
|
| | | }
|
| | | // 调用定时任务修改考勤记录
|
| | | List<User> userList = new ArrayList<>();
|
| | | if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
|
| | |
| | | throw new BadRequestException("只能删除自己的记录");
|
| | | }
|
| | | }
|
| | | if (attendanceLeave.get().getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)) {
|
| | | this.overtimeDeduction(attendanceLeave.get(), true);
|
| | | }
|
| | | attendanceLeaveRepository.deleteById(id);
|
| | | }
|
| | | }
|
| | |
| | | } else {
|
| | | attendanceLeave.setApprovalStatus(Constant.APPROVAL_STATUS_RETURNED);
|
| | | }
|
| | | attendanceLeaveRepository.save(attendanceLeave);
|
| | | AttendanceLeave attendanceLeaveSaved = attendanceLeaveRepository.save(attendanceLeave);
|
| | | if (attendanceLeaveSaved.getLeaveType().equals(Constant.LEAVE_TYPE_REPLACE)) {
|
| | | this.overtimeDeduction(attendanceLeaveSaved, false);
|
| | | }
|
| | |
|
| | | // 调用定时任务修改考勤记录
|
| | | List<User> userList = new ArrayList<>();
|
| | | if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
|
| | |
| | | }
|
| | | FileUtil.downloadExcel(list, response);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 调休假扣除方法
|
| | | * @param attendanceLeave
|
| | | * @param onlyRollback
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
| | | public synchronized void overtimeDeduction(AttendanceLeave attendanceLeave, Boolean onlyRollback) {
|
| | | // 回退旧分配记录
|
| | | OvertimeConsumedRecordQueryCriteria consumedCriteria = new OvertimeConsumedRecordQueryCriteria();
|
| | | consumedCriteria.setLeaveId(attendanceLeave.getId());
|
| | | List<OvertimeConsumedRecord> overtimeConsumedRecordList = overtimeConsumedRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, consumedCriteria, criteriaBuilder));
|
| | | Map<Long, Double> rollbackData = overtimeConsumedRecordList.stream().collect(Collectors.groupingBy(OvertimeConsumedRecord::getOvertimeId, Collectors.summingDouble(OvertimeConsumedRecord::getConsumedDuration)));
|
| | | for (Long overtimeId : rollbackData.keySet()) {
|
| | | AttendanceOvertime backAttendanceOvertime = attendanceOvertimeRepository.getById(overtimeId);
|
| | | backAttendanceOvertime.setRemainingDuration(backAttendanceOvertime.getRemainingDuration() + rollbackData.get(overtimeId));
|
| | | attendanceOvertimeRepository.save(backAttendanceOvertime);
|
| | | }
|
| | | overtimeConsumedRecordRepository.deleteAll(overtimeConsumedRecordList);
|
| | |
|
| | | if (onlyRollback) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 重新分配调休额度
|
| | | List<OvertimeConsumedRecord> consumedRecordList = new ArrayList<>();
|
| | | double remainingDuration = attendanceLeave.getLeaveDuration();
|
| | | LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(attendanceLeave.getLeaveStartTime().getTime() / 1000, 0, OffsetDateTime.now().getOffset());
|
| | | LocalDateTime startLocalDateTime = localDateTime.minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
| | | LocalDateTime endLocalDateTime = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
|
| | |
|
| | | // 查询可用调休申请
|
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | overtimeCriteria.setUserId(attendanceLeave.getUserId());
|
| | | overtimeCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startLocalDateTime), Timestamp.valueOf(endLocalDateTime)));
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime"));
|
| | |
|
| | | AttendanceOvertime currentAttendanceOvertime = new AttendanceOvertime();
|
| | |
|
| | | // 使用最早的额度依次扣减
|
| | | while (remainingDuration > 0 && currentAttendanceOvertime != null) {
|
| | | // 查看最早额度
|
| | | currentAttendanceOvertime = attendanceOvertimeList.stream().filter(ao -> ao.getRemainingDuration() > 0).findFirst().orElse(null);
|
| | |
|
| | | if (currentAttendanceOvertime != null) {
|
| | | // 获得扣除后剩余待扣除数额
|
| | | double deducted = currentAttendanceOvertime.subtractDuration(remainingDuration);
|
| | |
|
| | | // 生成扣减记录
|
| | | OvertimeConsumedRecord consumedRecord = new OvertimeConsumedRecord();
|
| | | consumedRecord.setLeaveId(attendanceLeave.getId());
|
| | | consumedRecord.setOvertimeId(currentAttendanceOvertime.getId());
|
| | | consumedRecord.setUserId(attendanceLeave.getUserId());
|
| | | consumedRecord.setConsumedDuration(remainingDuration - deducted);
|
| | | consumedRecordList.add(consumedRecord);
|
| | |
|
| | | remainingDuration = deducted;
|
| | | }
|
| | | }
|
| | |
|
| | | // 如果还有未扣减的额度,记录警告或异常
|
| | | if (remainingDuration > 0) {
|
| | | System.out.println("员工 " + attendanceLeave.getUserId() + " 的额度不足,剩余 " + remainingDuration + "H 未扣减");
|
| | | throw new BadRequestException("调休假额度不足");
|
| | | }
|
| | |
|
| | | // 保存记录
|
| | | attendanceOvertimeRepository.saveAll(attendanceOvertimeList);
|
| | | overtimeConsumedRecordRepository.saveAll(consumedRecordList);
|
| | | }
|
| | | } |
| | |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | Double yearTime = attendanceLeaveService.getYearTimeLength(attendanceMonth.getUserId()); |
| | | map.put("剩余年假", yearTime); |
| | | |
| | | Double overTime = attendanceLeaveService.getOverTimeLength(attendanceMonth.getUserId()); |
| | | Double overTime = attendanceLeaveService.getOverTimeLength(attendanceMonth.getUserId(), LocalDateTime.now()); |
| | | map.put("剩余调休假", overTime); |
| | | |
| | | map.put("上班缺卡次数", attendanceMonth.getOnCardNumber()); |
| | |
| | | import me.zhengjie.modules.approval.service.TemplateControlFieldService;
|
| | | import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
|
| | | import me.zhengjie.modules.attendance.domain.*;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceOvertimeRepository;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository;
|
| | | import me.zhengjie.modules.attendance.repository.OvertimeConsumedRecordRepository;
|
| | | import me.zhengjie.modules.attendance.service.AttendanceOvertimeService;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeDto;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria;
|
| | | import me.zhengjie.modules.attendance.service.dto.*;
|
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceOvertimeMapper;
|
| | | import me.zhengjie.modules.constant.Constant;
|
| | | import me.zhengjie.modules.salary.domain.NewSalary;
|
| | | import me.zhengjie.modules.salary.repository.NewSalaryRepository;
|
| | | import me.zhengjie.modules.system.domain.*;
|
| | | import me.zhengjie.modules.system.repository.DictDetailRepository;
|
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
|
| | |
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.math.BigDecimal;
|
| | | import java.math.RoundingMode;
|
| | | import java.sql.Timestamp;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.time.Duration;
|
| | | import java.time.*;
|
| | | import java.time.format.DateTimeFormatter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.time.temporal.ChronoUnit;
|
| | | import java.util.*;
|
| | | import java.util.function.Function;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | |
| | | private final UserRepository userRepository;
|
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository;
|
| | | private final ApproveEventRepository approveEventRepository;
|
| | | private final OvertimeConsumedRecordRepository overtimeConsumedRecordRepository;
|
| | | private final AttendanceGoOutRepository attendanceGoOutRepository;
|
| | | private final NewSalaryRepository newSalaryRepository;
|
| | | private final ApproveEventMapper approveEventMapper;
|
| | | private final TemplateControlFieldService templateControlFieldService;
|
| | |
|
| | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public AttendanceOvertimeDto create(AttendanceOvertime resources) {
|
| | |
|
| | | //查询考勤表是否有记录
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | String attDate = sdf.format(resources.getOvertimeStartTime());
|
| | | // // 查询考勤表是否有记录
|
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | // String attDate = sdf.format(resources.getOvertimeStartTime());
|
| | | // Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),attDate.substring(0,10));
|
| | | // if(ObjectUtils.isEmpty(attendance)){
|
| | | // throw new BadRequestException("考勤记录不存在");
|
| | | // }
|
| | |
|
| | | // 检验数据
|
| | | checkPrecondition(resources);
|
| | |
|
| | | // 查询日期配置
|
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(resources.getOvertimeStartTime().toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | | if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
|
| | | resources.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS);
|
| | |
| | | resources.setDateType(Constant.DATE_TYPE_WEEKEND);
|
| | | }
|
| | | resources.setApprovalStatus(Constant.OVERTIME_APPROVAL);
|
| | | resources.setRemainingDuration(resources.getOvertimeDuration());
|
| | |
|
| | | // 判断是否提交企微审批
|
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
|
| | |
| | | if(attendanceOvertime.getApprovalStatus().equals(Constant.OVERTIME_PASS) || attendanceOvertime.getApprovalStatus().equals(Constant.OVERTIME_RETURN)){
|
| | | throw new BadRequestException("审核通过或退回的不能进行修改");
|
| | | }
|
| | |
|
| | | // 检验数据
|
| | | checkPrecondition(resources);
|
| | |
|
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(resources.getOvertimeStartTime().toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | | if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
|
| | |
| | | User userInfo = userRepository.getOne(resources.getUserId());
|
| | | SysRostering sysRostering = userInfo.getSysRostering();
|
| | |
|
| | | long minutes = 0;
|
| | | // 获取开始与结束之间所有的日期
|
| | | List<LocalDate> allDates = new ArrayList<>();
|
| | | LocalDate currentDate = resources.getOvertimeStartTime().toLocalDateTime().toLocalDate();
|
| | | while (!currentDate.isAfter(resources.getOvertimeEndTime().toLocalDateTime().toLocalDate())) {
|
| | | allDates.add(currentDate);
|
| | | currentDate = currentDate.plusDays(1);
|
| | | }
|
| | | // 先排除工作日、日期类型为工作日的休息日(节假日和双休日)
|
| | | List<SysConfigHoliday> sysConfigHolidays = sysConfigHolidayRepository.findByHolidayDateBetween(Timestamp.valueOf(resources.getOvertimeStartTime().toLocalDateTime().toLocalDate().atStartOfDay()), Timestamp.valueOf(resources.getOvertimeEndTime().toLocalDateTime().toLocalDate().atStartOfDay()));
|
| | | Map<LocalDate, String> sysConfigHolidaysMap = sysConfigHolidays.stream().collect(Collectors.toMap(sch -> sch.getHolidayDate().toLocalDateTime().toLocalDate(), SysConfigHoliday::getDateType));
|
| | | List<LocalDate> overtimeDates = allDates;
|
| | |
|
| | | if (sysRostering.getWorkEndTime().isBefore(resources.getOvertimeEndTime().toLocalDateTime().toLocalTime()) &&
|
| | | sysRostering.getWorkEndTime().plusMinutes(30).isAfter(resources.getOvertimeEndTime().toLocalDateTime().toLocalTime())) {
|
| | | resources.setOvertimeEndTime(Timestamp.valueOf(resources.getOvertimeEndTime().toLocalDateTime().with(sysRostering.getWorkEndTime())));
|
| | | List<Calculate> resultParts = new ArrayList<>();
|
| | | List<Calculate> attendanceOvertimeParts = new ArrayList<>();
|
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | for (LocalDate date : overtimeDates) {
|
| | | // 休息时间管理
|
| | | if ((sysConfigHolidaysMap.containsKey(date) && sysConfigHolidaysMap.get(date).equals(Constant.DATE_TYPE_WEEKDAY)) ||
|
| | | (!(sysConfigHolidaysMap.containsKey(date) && (sysConfigHolidaysMap.get(date).equals(Constant.DATE_TYPE_WEEKEND) || sysConfigHolidaysMap.get(date).equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))) && !(date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY))
|
| | | ) {
|
| | | // 工作日(过0点上班时间和下班后30分钟,未过0点跳过统计)
|
| | | if (overtimeDates.size() > 1) {
|
| | | breakParts.add(new Calculate(date.atTime(sysRostering.getWorkStartTime()), date.atTime(sysRostering.getWorkEndTime()).plusMinutes(30)));
|
| | | } else {
|
| | | continue;
|
| | | }
|
| | | } else {
|
| | | // 休息日(午休和下班后30分钟)
|
| | | breakParts.add(new Calculate(date.atTime(sysRostering.getLunchStartTime()), date.atTime(sysRostering.getLunchEndTime())));
|
| | | breakParts.add(new Calculate(date.atTime(sysRostering.getWorkEndTime()), date.atTime(sysRostering.getWorkEndTime()).plusMinutes(30)));
|
| | | }
|
| | |
|
| | | if ((resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchStartTime()) || resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchStartTime()))
|
| | | && (resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getLunchEndTime()) || resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchEndTime()) )) {
|
| | | minutes = Duration.between(resources.getOvertimeStartTime().toLocalDateTime(), resources.getOvertimeEndTime().toLocalDateTime()).toMinutes() - 60;
|
| | | } else if (resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchStartTime()) || resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchStartTime()) ||
|
| | | resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getLunchEndTime()) || resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchEndTime())) {
|
| | | minutes = Duration.between(resources.getOvertimeStartTime().toLocalDateTime(), resources.getOvertimeEndTime().toLocalDateTime()).toMinutes();
|
| | | } else if (resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchStartTime()) && resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getLunchStartTime()) &&
|
| | | (resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchEndTime()) || resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchEndTime()))){
|
| | | minutes = Duration.between(resources.getOvertimeStartTime().toLocalDateTime().toLocalTime(), sysRostering.getLunchStartTime()).toMinutes();
|
| | | } else if ((resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchStartTime()) || resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchStartTime())) && resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getLunchEndTime())) {
|
| | | minutes = Duration.between(sysRostering.getLunchEndTime(), resources.getOvertimeEndTime().toLocalDateTime()).toMinutes();
|
| | | } else if (resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getLunchStartTime()) && (resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getLunchEndTime()) || resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().equals(sysRostering.getLunchEndTime()))) {
|
| | | minutes = Duration.between(sysRostering.getLunchEndTime(), resources.getOvertimeEndTime().toLocalDateTime()).toMinutes();
|
| | | // 全部加班时间管理
|
| | | LocalDateTime startTime = date.atStartOfDay();
|
| | | LocalDateTime endTime = date.atTime(LocalTime.MAX);
|
| | | if (resources.getOvertimeStartTime().toLocalDateTime().toLocalDate().equals(date)) {
|
| | | startTime = resources.getOvertimeStartTime().toLocalDateTime();
|
| | | }
|
| | |
|
| | | if ((resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().isBefore(sysRostering.getWorkEndTime()) || resources.getOvertimeStartTime().toLocalDateTime().toLocalTime().equals(sysRostering.getWorkEndTime()))
|
| | | && (resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().isAfter(sysRostering.getWorkEndTime().plusMinutes(30)) || resources.getOvertimeEndTime().toLocalDateTime().toLocalTime().equals(sysRostering.getWorkEndTime().plusMinutes(30)) )) {
|
| | | minutes -= 30;
|
| | | if (resources.getOvertimeEndTime().toLocalDateTime().toLocalDate().equals(date)) {
|
| | | endTime = resources.getOvertimeEndTime().toLocalDateTime();
|
| | | }
|
| | | attendanceOvertimeParts.add(new Calculate(startTime, endTime));
|
| | | }
|
| | | attendanceOvertimeParts.stream().sorted().reduce(new Stack<Calculate>(), (result, current) -> {
|
| | | // 删除重复时间,合并相连的时间段
|
| | | if (result.empty()) {
|
| | | result.push(current);
|
| | | return result;
|
| | | }
|
| | | Calculate last = result.peek();
|
| | | if (last.getEnd().isBefore(current.getStart())) {
|
| | | result.push(current);
|
| | | } else if (last.getEnd().isBefore(current.getEnd())) {
|
| | | last.setEnd(current.getEnd());
|
| | | }
|
| | | return result;
|
| | | }, (o1, o2) -> null).forEach(calculate -> {
|
| | | List<Calculate> currentParts = new ArrayList<>();
|
| | | currentParts.add(calculate);
|
| | | // 去除休息时间:午休、下班后30分钟等
|
| | | for (Calculate breakPart : breakParts) {
|
| | | List<Calculate> tempParts = new ArrayList<>();
|
| | | for (Calculate current : currentParts) {
|
| | | if ((current.getStart().isBefore(breakPart.getStart()) && current.getEnd().isAfter(breakPart.getStart()))
|
| | | || (current.getStart().isBefore(breakPart.getEnd()) && current.getEnd().isAfter(breakPart.getEnd()))) {
|
| | | Calculate calculate1 = new Calculate(current.getStart(), breakPart.getStart());
|
| | | Calculate calculate2 = new Calculate(breakPart.getEnd(), current.getEnd());
|
| | | if (calculate1.getStart().isBefore(calculate1.getEnd())) {
|
| | | tempParts.add(calculate1);
|
| | | }
|
| | | if (calculate2.getStart().isBefore(calculate2.getEnd())) {
|
| | | tempParts.add(calculate2);
|
| | | }
|
| | | } else {
|
| | | tempParts.add(current);
|
| | | }
|
| | | }
|
| | | currentParts = tempParts;
|
| | | }
|
| | | // 将处理完所有休息区间后的结果添加到最终结果
|
| | | resultParts.addAll(currentParts);
|
| | |
|
| | | double hours = new BigDecimal((double) minutes / 60).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | });
|
| | |
|
| | | attendanceOvertimeDto.setOvertimeDuration(hours);
|
| | | BigDecimal resultTime = resultParts.stream()
|
| | | .map(calculate -> ChronoUnit.SECONDS.between(calculate.getStart(), calculate.getEnd()))
|
| | | .reduce(new BigDecimal(0),
|
| | | (total, current) -> total.add(BigDecimal.valueOf(current)),
|
| | | BigDecimal::add)
|
| | | .divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP
|
| | | );
|
| | |
|
| | | attendanceOvertimeDto.setOvertimeDuration(resultTime.max(BigDecimal.ZERO).doubleValue());
|
| | | return attendanceOvertimeDto;
|
| | | }
|
| | |
|
| | |
| | | AttendanceOvertime attendanceOvertime = attendanceOvertimeRepository.findById(resources.getId()).orElseGet(AttendanceOvertime::new);
|
| | | ValidationUtil.isNull( attendanceOvertime.getId(),"AttendanceOvertime","id",resources.getId());
|
| | | attendanceOvertime.copy(resources);
|
| | | if (attendanceOvertime.getApprovalStatus().equals(Constant.OVERTIME_APPROVAL) || attendanceOvertime.getApprovalStatus().equals(Constant.OVERTIME_RETURN)) {
|
| | | OvertimeConsumedRecordQueryCriteria consumedCriteria = new OvertimeConsumedRecordQueryCriteria();
|
| | | consumedCriteria.setOvertimeId(attendanceOvertime.getId());
|
| | | Long haveCount = overtimeConsumedRecordRepository.count((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, consumedCriteria, criteriaBuilder));
|
| | | if (haveCount > 0) {
|
| | | throw new BadRequestException("调休时长已占用,不可撤销");
|
| | | }
|
| | | }
|
| | | attendanceOvertimeRepository.save(attendanceOvertime);
|
| | | }
|
| | |
|
| | | public void checkPrecondition(AttendanceOvertime resources) {
|
| | | // 验证是否有对应的考勤或外出记录
|
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(), resources.getOvertimeStartTime().toLocalDateTime().toLocalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(resources.getUserId(), resources.getOvertimeStartTime().toLocalDateTime(), resources.getOvertimeEndTime().toLocalDateTime());
|
| | | Boolean attendanceFlag = attendance == null || attendance.getActualWorkStartTime() == null || attendance.getActualWorkEndTime() == null || attendance.getActualWorkStartTime().toLocalDateTime().compareTo(resources.getOvertimeStartTime().toLocalDateTime()) > 0 || attendance.getActualWorkEndTime().toLocalDateTime().compareTo(resources.getOvertimeEndTime().toLocalDateTime()) < 0;
|
| | | Boolean attendanceGoOutFlag = attendanceGoOutList.isEmpty() || resources.getOvertimeDuration() > attendanceGoOutList.stream().collect(Collectors.summingDouble(AttendanceGoOut::getOutDuration)) || resources.getOvertimeStartTime().compareTo(attendanceGoOutList.stream().map(AttendanceGoOut::getOutStartTime).min(Timestamp::compareTo).orElse(null)) < 0 || resources.getOvertimeEndTime().compareTo(attendanceGoOutList.stream().map(AttendanceGoOut::getOutEndTime).max(Timestamp::compareTo).orElse(null)) > 0;
|
| | | if (attendanceFlag && attendanceGoOutFlag) {
|
| | | throw new BadRequestException("缺少对应的考勤记录或外出记录。");
|
| | | }
|
| | |
|
| | | // 验证工资是否已结算(如已结算不可创建,因调休可能会和加班时间重合)
|
| | | List<NewSalary> salaryList = newSalaryRepository.findByUserIdAndSalaryYearMonth(resources.getUserId(), Timestamp.valueOf(resources.getOvertimeStartTime().toLocalDateTime().toLocalDate().withDayOfMonth(1).atStartOfDay()));
|
| | | if (salaryList.size() > 0) {
|
| | | throw new BadRequestException("该月工资信息已生成,请确认后重试。");
|
| | | }
|
| | | }
|
| | | } |
| | |
| | |
|
| | | @Override
|
| | | public Double queryAttendanceHolidaysOverTimeHours(AttendanceQueryCriteria criteria) {
|
| | |
|
| | | LocalDate startDate = LocalDate.parse(criteria.getTargetYearMonth(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
| | | // 结算结算三个月前的(法定节假日)
|
| | | LocalDate startDate = LocalDate.parse(criteria.getTargetYearMonth(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).minusMonths(3L);
|
| | | LocalDate endDate = startDate.plusMonths(1).minusDays(1);
|
| | | // 节日检索类
|
| | | SysConfigHolidayQueryCriteria sysConfigHolidayQueryCriteria = new SysConfigHolidayQueryCriteria();
|
| | | sysConfigHolidayQueryCriteria.setHolidayDateLike(criteria.getTargetYearMonth().substring(0,7));
|
| | | // 获取本月节日列表
|
| | | sysConfigHolidayQueryCriteria.setHolidayDateLike(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")));
|
| | | // 获取三个月前节日列表
|
| | | List<SysConfigHoliday> sysConfigHolidayMonthList = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,sysConfigHolidayQueryCriteria,criteriaBuilder));
|
| | | if (sysConfigHolidayMonthList.isEmpty()) {
|
| | | return 0.0D;
|
| | |
| | | .mapToDouble(sysConfigHoliday -> {
|
| | | for (AttendanceOvertime attendanceOvertime : attendanceOvertimeList) {
|
| | | if (sysConfigHoliday.getHolidayDate().toLocalDateTime().isEqual(attendanceOvertime.getOvertimeStartTime().toLocalDateTime().truncatedTo(ChronoUnit.DAYS))) {
|
| | | return attendanceOvertime.getOvertimeDuration();
|
| | | return attendanceOvertime.getRemainingDuration();
|
| | | }
|
| | | }
|
| | | return 0.0D;
|
| | | }).sum();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double queryAttendanceWeekendOverTimeHours(AttendanceQueryCriteria criteria) {
|
| | | // 结算结算三个月前的
|
| | | LocalDate startDate = LocalDate.parse(criteria.getTargetYearMonth(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).minusMonths(3L);
|
| | | LocalDate endDate = startDate.plusMonths(1).minusDays(1);
|
| | | // 节日检索类
|
| | | SysConfigHolidayQueryCriteria sysConfigHolidayQueryCriteria = new SysConfigHolidayQueryCriteria();
|
| | | sysConfigHolidayQueryCriteria.setHolidayDateLike(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")));
|
| | | // 获取三个月前节日列表
|
| | | List<SysConfigHoliday> sysConfigHolidayMonthList = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,sysConfigHolidayQueryCriteria,criteriaBuilder));
|
| | |
|
| | | // 加班信息
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
|
| | | Map<LocalDate, String> sysConfigHolidayMap = sysConfigHolidayMonthList.stream().collect(Collectors.toMap(sch -> sch.getHolidayDate().toLocalDateTime().toLocalDate(), SysConfigHoliday::getDateType));
|
| | |
|
| | | return attendanceOvertimeList.stream().mapToDouble(ao -> {
|
| | | LocalDate localDate = ao.getOvertimeStartTime().toLocalDateTime().toLocalDate();
|
| | | DayOfWeek dayOfWeek = ao.getOvertimeStartTime().toLocalDateTime().toLocalDate().getDayOfWeek();
|
| | | if ((sysConfigHolidayMap.containsKey(localDate) &&
|
| | | sysConfigHolidayMap.get(localDate).equals(Constant.DATE_TYPE_WEEKEND) &&
|
| | | !sysConfigHolidayMap.get(localDate).equals(Constant.DATE_TYPE_WEEKDAY) &&
|
| | | !sysConfigHolidayMap.get(localDate).equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) ||
|
| | | (dayOfWeek.equals(DayOfWeek.SATURDAY) || dayOfWeek.equals(DayOfWeek.SUNDAY))
|
| | | ) {
|
| | | return ao.getRemainingDuration();
|
| | | }
|
| | | return 0.0D;
|
| | | }).sum();
|
| | |
| | | // 正常时间管理
|
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30)));
|
| | | // 查询调休(因工作日加班过0点加班时间可转调休的规定,部分调休与加班时间重复,需要扣除这部分时间,具体可咨询Lief)
|
| | | AttendanceOvertimeQueryCriteria aoCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | aoCriteria.setUserId(criteria.getUserId());
|
| | | aoCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startOfDate), Timestamp.valueOf(endOfDate)));
|
| | | aoCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, aoCriteria, criteriaBuilder));
|
| | | breakParts.addAll(attendanceOvertimeList.stream().map(ao -> new Calculate(ao.getOvertimeStartTime().toLocalDateTime(), ao.getOvertimeEndTime().toLocalDateTime())).collect(Collectors.toList()));
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | |
| | | Long result = resultParts.stream()
|
| | | .mapToLong(calculate -> ChronoUnit.MINUTES.between(calculate.getStart(), calculate.getEnd()))
|
| | | .sum();
|
| | | // 加班时长不足0.5小时的部分不计入加班统计。
|
| | | long halfHour = result / 30;
|
| | | return BigDecimal.valueOf(halfHour).multiply(BigDecimal.valueOf(0.5));
|
| | | }).reduce(BigDecimal::add).get().doubleValue();
|
| | |
| | | .mapToDouble(sysConfigHoliday -> { |
| | | for (AttendanceOvertime attendanceOvertime : attendanceOvertimeList) { |
| | | if (sysConfigHoliday.getHolidayDate().toLocalDateTime().isEqual(attendanceOvertime.getOvertimeStartTime().toLocalDateTime().truncatedTo(ChronoUnit.DAYS))) { |
| | | return attendanceOvertime.getOvertimeDuration(); |
| | | return attendanceOvertime.getRemainingDuration(); |
| | | } |
| | | } |
| | | return 0.0D; |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceOvertime; |
| | | import me.zhengjie.modules.attendance.domain.OvertimeConsumedRecord; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceOvertimeRepository; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.system.service.dto.UserQueryCriteria; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.attendance.repository.OvertimeConsumedRecordRepository; |
| | | import me.zhengjie.modules.attendance.service.OvertimeConsumedRecordService; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordDto; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.mapstruct.OvertimeConsumedRecordMapper; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class OvertimeConsumedRecordServiceImpl implements OvertimeConsumedRecordService { |
| | | |
| | | private final OvertimeConsumedRecordRepository overtimeConsumedRecordRepository; |
| | | private final AttendanceOvertimeRepository attendanceOvertimeRepository; |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final UserRepository userRepository; |
| | | private final OvertimeConsumedRecordMapper overtimeConsumedRecordMapper; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(OvertimeConsumedRecordQueryCriteria criteria, Pageable pageable){ |
| | | Page<OvertimeConsumedRecord> page = overtimeConsumedRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | return PageUtil.toPage(page.map(overtimeConsumedRecordMapper::toDto)); |
| | | } |
| | | |
| | | @Override |
| | | public List<OvertimeConsumedRecordDto> queryAll(OvertimeConsumedRecordQueryCriteria criteria){ |
| | | return overtimeConsumedRecordMapper.toDto(overtimeConsumedRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public OvertimeConsumedRecordDto findById(Long id) { |
| | | OvertimeConsumedRecord overtimeConsumedRecord = overtimeConsumedRecordRepository.findById(id).orElseGet(OvertimeConsumedRecord::new); |
| | | ValidationUtil.isNull(overtimeConsumedRecord.getId(),"OvertimeConsumedRecord","id",id); |
| | | return overtimeConsumedRecordMapper.toDto(overtimeConsumedRecord); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public OvertimeConsumedRecordDto create(OvertimeConsumedRecord resources) { |
| | | return overtimeConsumedRecordMapper.toDto(overtimeConsumedRecordRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(OvertimeConsumedRecord resources) { |
| | | OvertimeConsumedRecord overtimeConsumedRecord = overtimeConsumedRecordRepository.findById(resources.getId()).orElseGet(OvertimeConsumedRecord::new); |
| | | ValidationUtil.isNull( overtimeConsumedRecord.getId(),"OvertimeConsumedRecord","id",resources.getId()); |
| | | overtimeConsumedRecord.copy(resources); |
| | | overtimeConsumedRecordRepository.save(overtimeConsumedRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | overtimeConsumedRecordRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<OvertimeConsumedRecordDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (OvertimeConsumedRecordDto overtimeConsumedRecord : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("请假单关联ID", overtimeConsumedRecord.getLeaveId()); |
| | | map.put("调休单关联ID", overtimeConsumedRecord.getOvertimeId()); |
| | | map.put("消耗工时", overtimeConsumedRecord.getConsumedDuration()); |
| | | map.put("创建时间", overtimeConsumedRecord.getCreateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void allConsumedDeduction() { |
| | | // 获取用户信息 |
| | | UserQueryCriteria userCriteria = new UserQueryCriteria(); |
| | | userCriteria.setEnabled(true); |
| | | List<User> userList = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, userCriteria, criteriaBuilder)); |
| | | |
| | | for (User user : userList) { |
| | | // 重置调休可用时长 |
| | | attendanceOvertimeRepository.resetRemainingDuration(user.getId()); |
| | | // 删除扣减记录 |
| | | overtimeConsumedRecordRepository.deleteAllByUserId(user.getId()); |
| | | |
| | | // 查询可用调休申请 |
| | | AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria(); |
| | | overtimeCriteria.setApprovalStatus(Constant.OVERTIME_PASS); |
| | | overtimeCriteria.setUserId(user.getId()); |
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, overtimeCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "overtimeStartTime")); |
| | | |
| | | // 查询审核中/已通过调休假 |
| | | AttendanceLeaveQueryCriteria leaveCriteria = new AttendanceLeaveQueryCriteria(); |
| | | leaveCriteria.setLeaveType(Constant.LEAVE_TYPE_REPLACE); |
| | | leaveCriteria.setApprovalStatusList(Arrays.asList(Constant.APPROVAL_STATUS_UNDER_APPROVAL, Constant.APPROVAL_STATUS_PASSED)); |
| | | leaveCriteria.setUserId(user.getId()); |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, leaveCriteria, criteriaBuilder), Sort.by(Sort.Direction.ASC, "leaveStartTime")); |
| | | |
| | | List<OvertimeConsumedRecord> consumedRecordList = new ArrayList<>(); |
| | | |
| | | for (AttendanceLeave attendanceLeave : attendanceLeaveList) { |
| | | double remainingDuration = attendanceLeave.getLeaveDuration(); |
| | | LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(attendanceLeave.getLeaveStartTime().getTime(), 0, OffsetDateTime.now().getOffset()); |
| | | Long startSecond = localDateTime.minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).atZone(ZoneId.systemDefault()).toEpochSecond(); |
| | | Long endSecond = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).atZone(ZoneId.systemDefault()).toEpochSecond(); |
| | | AttendanceOvertime currentAttendanceOvertime = new AttendanceOvertime(); |
| | | |
| | | // 使用最早的额度依次扣减 |
| | | while (remainingDuration > 0 && currentAttendanceOvertime != null) { |
| | | // 查看最早额度但不移除 |
| | | currentAttendanceOvertime = attendanceOvertimeList.stream().filter(ao -> { |
| | | Long overtimeTime = LocalDateTime.ofEpochSecond(attendanceLeave.getLeaveStartTime().getTime(), 0, OffsetDateTime.now().getOffset()).atZone(ZoneId.systemDefault()).toEpochSecond(); |
| | | return ao.getRemainingDuration() > 0 && overtimeTime >= startSecond && overtimeTime <= endSecond; |
| | | }).findFirst().orElse(null); |
| | | |
| | | if (currentAttendanceOvertime != null) { |
| | | // 获得扣除后剩余待扣除数额 |
| | | double deducted = currentAttendanceOvertime.subtractDuration(remainingDuration); |
| | | |
| | | // 生成扣减记录 |
| | | OvertimeConsumedRecord consumedRecord = new OvertimeConsumedRecord(); |
| | | consumedRecord.setLeaveId(attendanceLeave.getId()); |
| | | consumedRecord.setOvertimeId(currentAttendanceOvertime.getId()); |
| | | consumedRecord.setUserId(user.getId()); |
| | | consumedRecord.setConsumedDuration(remainingDuration - deducted); |
| | | consumedRecordList.add(consumedRecord); |
| | | |
| | | remainingDuration = deducted; |
| | | } |
| | | } |
| | | |
| | | // 如果还有未扣减的额度,记录警告或异常 |
| | | if (remainingDuration > 0) { |
| | | System.out.println("员工 " + attendanceLeave.getUserId() + " 的额度不足,剩余 " + remainingDuration + "H 未扣减"); |
| | | } |
| | | } |
| | | |
| | | // 保存记录 |
| | | attendanceOvertimeRepository.saveAll(attendanceOvertimeList); |
| | | overtimeConsumedRecordRepository.saveAll(consumedRecordList); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.attendance.domain.OvertimeConsumedRecord; |
| | | import me.zhengjie.modules.attendance.service.dto.OvertimeConsumedRecordDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author baolh |
| | | * @date 2025-09-28 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface OvertimeConsumedRecordMapper extends BaseMapper<OvertimeConsumedRecordDto, OvertimeConsumedRecord> { |
| | | |
| | | } |
| | |
| | | // 费用类型:客户关系
|
| | | public static final String EXPENSE_TYPE_CUSTOMER_RELATIONSHIP = "expense_type_customer_relationship";
|
| | |
|
| | | public static final String ATTENDANCE_BUSINESS_TRAVEL_CATEGORY = "attendance_business_travel_category";
|
| | | public static final String ATTENDANCE_BUSINESS_TRAVEL_CATEGORY = "business_travel_category";
|
| | | public static final String ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL = "attendance_business_travel_category_travel";
|
| | | public static final String ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE = "attendance_business_travel_category_same_place";
|
| | |
|
| | |
| | | resources.setContractNumber(contractNumber.toString()); |
| | | if (companyId != null) { |
| | | resources.setCompanyId(companyId); |
| | | } else { |
| | | throw new BadRequestException("未匹配到所属公司,所属公司不能为空。"); |
| | | } |
| | | } |
| | | |
| | |
| | | Double yearTime = attendanceLeaveService.getYearTimeLength(insertData.get(i).getUserId());
|
| | | attendanceMonthLeave.setSurplusDuration(yearTime);
|
| | | } else if (leaveTpeList.get(i2).equals(Constant.LEAVE_TYPE_LACTATION_LEAVE)) {
|
| | | Double yearTime = attendanceLeaveService.getOverTimeLength(insertData.get(i).getUserId());
|
| | | Double yearTime = attendanceLeaveService.getOverTimeLength(insertData.get(i).getUserId(), LocalDateTime.now());
|
| | | attendanceMonthLeave.setSurplusDuration(yearTime);
|
| | | }
|
| | | attendanceMonthLeaveRepository.save(attendanceMonthLeave);
|
| | |
| | | Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue)); |
| | | if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_MSG)) { |
| | | // 发送消息 |
| | | WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl(); |
| | | wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY)); |
| | | wxCpService.setWxCpConfigStorage(wxCpDefaultConfig); |
| | | wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | String webhookUrl = wxCpService.getWxCpConfigStorage().getApiUrl("/cgi-bin/webhook/send?key=") + robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY); |
| | | wxCpService.getGroupRobotService().sendText(webhookUrl, robotParamMap.get(Constant.REMIND_REPORT_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | |
| | | Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue)); |
| | | if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_SUCCESS_MSG)) { |
| | | // 发送周报生成成功消息 |
| | | WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl(); |
| | | wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY)); |
| | | wxCpService.setWxCpConfigStorage(wxCpDefaultConfig); |
| | | wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | String webhookUrl = wxCpService.getWxCpConfigStorage().getApiUrl("/cgi-bin/webhook/send?key=") + robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY); |
| | | wxCpService.getGroupRobotService().sendText(webhookUrl, robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | |
| | | @ApiModelProperty(value = "加班工资") |
| | | private BigDecimal overtimeAllowance = BigDecimal.ZERO; |
| | | |
| | | @Column(name = "`comptime_allowance`") |
| | | @ApiModelProperty(value = "调休结算工资") |
| | | private BigDecimal comptimeAllowance = BigDecimal.ZERO; |
| | | |
| | | @Column(name = "`accumulation_fund`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "公积金基数") |
| | |
| | | private BigDecimal overtimeAllowance; |
| | | |
| | | /** |
| | | * 调休结算工资 |
| | | */ |
| | | private BigDecimal comptimeAllowance; |
| | | |
| | | /** |
| | | * 全勤小时数 |
| | | */ |
| | | private Double fullDays; |
| | |
| | | map.put("全勤小时数", newSalaryDto.getFullDays());
|
| | | map.put("缺勤小时数", newSalaryDto.getAbsenceDays());
|
| | | map.put("实际基础工资", newSalaryDto.getActualBasicWage());
|
| | | map.put("其他补助", newSalaryDto.getTravelAllowance().add(newSalaryDto.getOvertimeAllowance()));
|
| | | map.put("其他补助", newSalaryDto.getTravelAllowance().add(newSalaryDto.getOvertimeAllowance()).add(newSalaryDto.getComptimeAllowance()));
|
| | | // map.put("绩效工资", newSalaryDto.getAchievementsWage());
|
| | | // map.put("应完成绩效工时", newSalaryDto.getNeedCompletedAchievementsHours());
|
| | | // map.put("已完成绩效工时", newSalaryDto.getAlreadyCompletedAchievementsHours());
|
| | |
| | | attendanceQueryCriteria.setTargetYearMonth(targetYearMonth);
|
| | | // 查询某月平日加班小时数
|
| | | Double attendanceHours = attendanceService.queryAttendanceOverTimeHours(attendanceQueryCriteria);
|
| | | // 查询某月节假日加班小时数
|
| | | // 查询某月需结算的(结算三个月前的,如4月时结算1月份的)节假日调休小时数
|
| | | Double attendanceHolidayHours = attendanceService.queryAttendanceHolidaysOverTimeHours(attendanceQueryCriteria);
|
| | | // 查询某月需结算的(结算三个月前的,如4月时结算1月份的)双休日调休小时数
|
| | | Double attendanceWeekendHours = attendanceService.queryAttendanceWeekendOverTimeHours(attendanceQueryCriteria);
|
| | |
|
| | | UserLevelWageQueryCriteria criteria = new UserLevelWageQueryCriteria();
|
| | | criteria.setUserId(userId);
|
| | |
| | | } else {
|
| | | newSalary.setOvertimeAllowance(newSalary.getBasicWage().multiply(BigDecimal.valueOf(attendanceHours)).divide(BigDecimal.valueOf(newSalary.getFullDays()), 2, RoundingMode.HALF_UP));
|
| | | }
|
| | | // 节假日加班费
|
| | | newSalary.setOvertimeAllowance(newSalary.getOvertimeAllowance().add(newSalary.getBasicWage().multiply(BigDecimal.valueOf(attendanceHolidayHours)).multiply(BigDecimal.valueOf(3)).divide(BigDecimal.valueOf(21.75), 2, RoundingMode.HALF_UP)));
|
| | | // 调休结算费(除数174是21.75 * 8得出,21.75是每月平均天数,8是每日工作小时数)
|
| | | newSalary.setComptimeAllowance(newSalary.getBasicWage().multiply(BigDecimal.valueOf(attendanceHolidayHours)).multiply(BigDecimal.valueOf(3)).divide(BigDecimal.valueOf(174), 2, RoundingMode.HALF_UP)
|
| | | .add(newSalary.getBasicWage().multiply(BigDecimal.valueOf(attendanceWeekendHours)).divide(BigDecimal.valueOf(174), 2, RoundingMode.HALF_UP))
|
| | | );
|
| | | // 税前工资累计
|
| | | newSalary.setPreTaxAmount(newSalary.getPreTaxAmount().add(newSalary.getOvertimeAllowance()));
|
| | | newSalary.setPreTaxAmount(newSalary.getPreTaxAmount().add(newSalary.getOvertimeAllowance()).add(newSalary.getComptimeAllowance()));
|
| | | // 返回
|
| | | return newSalary;
|
| | | }
|
| | |
| | | import me.zhengjie.modules.attendance.domain.Attendance;
|
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel;
|
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
|
| | | import me.zhengjie.modules.attendance.domain.Calculate;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceCardreplacementRepository;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
|
| | |
| | | import java.time.Duration;
|
| | | import java.time.LocalDate;
|
| | | import java.time.LocalDateTime;
|
| | | import java.time.ZoneId;
|
| | | import java.time.format.DateTimeFormatter;
|
| | | import java.time.temporal.ChronoUnit;
|
| | | import java.time.temporal.TemporalAdjusters;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
| | | String sdfFirstDate = DateUtil.getFirstDayOfMonthFull(sdfDate);
|
| | | // 目标年月末字符串
|
| | | String sdfLastDate = DateUtil.getLastDayOfMonthFull(sdfDate);
|
| | | // 出勤天数
|
| | | // 出勤天数, 如果包含双休和节假日,则减去对应天数
|
| | | List<Attendance> attendanceRecordList = attendanceRepository.findAllByUserAndDate(userId, sdfFirstDate, sdfLastDate);
|
| | | int numDay = 0;
|
| | | for (Attendance attendance : attendanceRecordList) {
|
| | | if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_REST)) {
|
| | | if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND) && !attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
|
| | | numDay++;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | // 法定节假日
|
| | | List<String> holiday = new ArrayList<>();
|
| | | // 调休的工作日
|
| | | List<String> workingHoliday = new ArrayList<>();
|
| | | // 天数
|
| | | int shouldWordDays = 0;
|
| | | List<SysConfigHoliday> holidayConfigurationList = sysConfigHolidayRepository.findAll();
|
| | |
| | | || holidayConfiguration.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)
|
| | | || holidayConfiguration.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) {
|
| | | holiday.add(sdf.format(holidayConfiguration.getHolidayDate()));
|
| | | } else if (holidayConfiguration.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)) {
|
| | | workingHoliday.add(sdf.format(holidayConfiguration.getHolidayDate()));
|
| | | }
|
| | | }
|
| | | // 获取当月所有日期
|
| | |
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(isWeekEnd);
|
| | | if (isWeekEnd.compareTo(sdf.parse(todayDay)) <= 0) {
|
| | | if (!holiday.contains(date) && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
|
| | | if ((!holiday.contains(date) && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) || workingHoliday.contains(date)) {
|
| | | shouldWordDays += 1;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | User user = userRepository.getById(userId);
|
| | | // 考勤上午时间
|
| | | Double attCheckOnDuration = 0.0;
|
| | | // 考勤下午时间
|
| | | Double attCheckOffDuration = 0.0;
|
| | | BigDecimal resultTime = null;
|
| | | List<Calculate> resultParts = new ArrayList<>();
|
| | | List<Calculate> calculateList = new ArrayList<>();
|
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | for (Attendance attendance : attendanceRecordList) {
|
| | | // 上班打卡时间不为空并且打卡状态不为出差外出的考勤记录
|
| | | if (ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
|
| | | LocalDateTime attCheckOnTime = attendance.getActualWorkStartTime().toLocalDateTime();
|
| | | LocalDateTime scheduleStartTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchStartTime().toString() + ":00", formatter2);
|
| | | if (attCheckOnTime.compareTo(scheduleStartTime) <= 0) {
|
| | | // 获得两个时间之间的相差值
|
| | | Duration duration = Duration.between(attCheckOnTime, scheduleStartTime);
|
| | | Long minutes = duration.toMinutes();
|
| | | Double hour = Double.valueOf(String.valueOf(new BigDecimal(Double.valueOf(minutes) / 60).setScale(2, BigDecimal.ROUND_HALF_UP)));
|
| | | attCheckOnDuration = attCheckOnDuration + hour;
|
| | | }
|
| | | }
|
| | | // 下班打卡时间不为空并且打卡状态不为出差外出的考勤记录
|
| | | if (ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
|
| | | LocalDateTime attCheckOffTime = attendance.getActualWorkEndTime().toLocalDateTime();
|
| | | LocalDateTime scheduleEndTime = LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchEndTime().toString() + ":00", formatter2);
|
| | | if (attCheckOffTime.compareTo(scheduleEndTime) > 0) {
|
| | | // 获得两个时间之间的相差值
|
| | | Duration duration = Duration.between(scheduleEndTime, attCheckOffTime);
|
| | | Long minutes = duration.toMinutes();
|
| | | Double hour = Double.valueOf(String.valueOf(new BigDecimal(Double.valueOf(minutes) / 60).setScale(2, BigDecimal.ROUND_HALF_UP)));
|
| | | attCheckOffDuration = attCheckOffDuration + hour;
|
| | | if (ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) &&
|
| | | !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) &&
|
| | | !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)) {
|
| | | calculateList.add(new Calculate(attendance.getActualWorkStartTime().toLocalDateTime(), attendance.getActualWorkEndTime().toLocalDateTime()));
|
| | | // 休息时间管理(午休和下班后30分钟)
|
| | | breakParts.add(new Calculate(LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchStartTime().toString() + ":00", formatter2), LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getLunchEndTime().toString() + ":00", formatter2)));
|
| | | breakParts.add(new Calculate(LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00", formatter2), LocalDateTime.parse(attendance.getAttendanceDate().toString().substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00", formatter2).plusMinutes(30)));
|
| | | }
|
| | | }
|
| | | calculateList.stream().sorted().reduce(new Stack<Calculate>(), (result, current) -> {
|
| | | // 删除重复时间,合并相连的时间段
|
| | | if (result.empty()) {
|
| | | result.push(current);
|
| | | return result;
|
| | | }
|
| | | Calculate last = result.peek();
|
| | | if (last.getEnd().isBefore(current.getStart())) {
|
| | | result.push(current);
|
| | | } else if (last.getEnd().isBefore(current.getEnd())) {
|
| | | last.setEnd(current.getEnd());
|
| | | }
|
| | | return result;
|
| | | }, (o1, o2) -> null).forEach(calculate -> {
|
| | | List<Calculate> currentParts = new ArrayList<>();
|
| | | currentParts.add(calculate);
|
| | | // 去除休息时间:午休、下班后30分钟
|
| | | for (Calculate breakPart : breakParts) {
|
| | | List<Calculate> tempParts = new ArrayList<>();
|
| | | for (Calculate current : currentParts) {
|
| | | if ((current.getStart().isBefore(breakPart.getStart()) && current.getEnd().isAfter(breakPart.getStart()))
|
| | | || (current.getStart().isBefore(breakPart.getEnd()) && current.getEnd().isAfter(breakPart.getEnd()))) {
|
| | | Calculate calculate1 = new Calculate(current.getStart(), breakPart.getStart());
|
| | | Calculate calculate2 = new Calculate(breakPart.getEnd(), current.getEnd());
|
| | | if (calculate1.getStart().isBefore(calculate1.getEnd())) {
|
| | | tempParts.add(calculate1);
|
| | | }
|
| | | if (calculate2.getStart().isBefore(calculate2.getEnd())) {
|
| | | tempParts.add(calculate2);
|
| | | }
|
| | | } else {
|
| | | tempParts.add(current);
|
| | | }
|
| | | }
|
| | | currentParts = tempParts;
|
| | | }
|
| | | // 将处理完所有休息区间后的结果添加到最终结果
|
| | | resultParts.addAll(currentParts);
|
| | | });
|
| | |
|
| | | resultTime = resultParts.stream()
|
| | | .map(calculate -> ChronoUnit.SECONDS.between(calculate.getStart(), calculate.getEnd()))
|
| | | .reduce(new BigDecimal(0),
|
| | | (total, current) -> total.add(BigDecimal.valueOf(current)),
|
| | | BigDecimal::add)
|
| | | .divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP
|
| | | );
|
| | |
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
| | | String startTime = sdfFirstDate.substring(0, 10) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime());
|
| | | String endTime = todayDay.substring(0, 10) + " " + dateTimeFormatter.format(user.getSysRostering().getWorkEndTime());
|
| | |
| | | // 出差时长
|
| | | Double bussTimes = 0.0;
|
| | | // 查询出差表
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId, Timestamp.valueOf(sdfFirstDate).toLocalDateTime(), Timestamp.valueOf(todayDay.substring(0, 10) + " " + "00:00:00").toLocalDateTime());
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId, Timestamp.valueOf(sdfFirstDate).toLocalDateTime(), Timestamp.valueOf(sdfLastDate.substring(0, 10) + " 23:59:59").toLocalDateTime());
|
| | | for (AttendanceBusinessTravel attendanceBusinessTravel : attendanceBusinessTravelList) {
|
| | | bussTimes = bussTimes + attendanceBusinessTravel.getTravelDuration();
|
| | | }
|
| | | returnData.put("Times", attCheckOnDuration + attCheckOffDuration + goOutTimes + (bussTimes * 8));
|
| | |
|
| | | // 实际工作时长
|
| | | returnData.put("Times", (resultTime.max(BigDecimal.ZERO).doubleValue()) + goOutTimes + (bussTimes * 8));
|
| | |
|
| | | // 查询某月已完成工时
|
| | | DecimalFormat decimalFormat = new DecimalFormat("0.##");
|
| | |
| | | AttendanceQueryCriteria attendanceQueryCriteria = new AttendanceQueryCriteria();
|
| | | attendanceQueryCriteria.setUserId(userId);
|
| | | attendanceQueryCriteria.setTargetYearMonth(sdfDate.substring(0, 7) + "-01");
|
| | | attendanceQueryCriteria.setDateType(Constant.DATE_TYPE_WEEKDAY);
|
| | | Double attendanceOverTimeHours = attendanceService.queryAttendanceOverTimeHours(attendanceQueryCriteria);
|
| | | returnData.put("attendanceOverTimeHours", attendanceOverTimeHours);
|
| | |
|
| | |
| | | AttendanceLeaveQueryCriteria attendanceLeaveQueryCriteria = new AttendanceLeaveQueryCriteria();
|
| | | attendanceLeaveQueryCriteria.setUserId(userId);
|
| | | attendanceLeaveQueryCriteria.setLeaveStartTimeLike(sdfDate.substring(0, 7) + "%");
|
| | | attendanceLeaveQueryCriteria.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
|
| | | List<AttendanceLeaveDto> attendanceLeaveDtos = attendanceLeaveService.queryAll(attendanceLeaveQueryCriteria);
|
| | | double leaveTimeHours = attendanceLeaveDtos.stream().mapToDouble(AttendanceLeaveDto::getLeaveDuration).sum();
|
| | | double leaveTimeHours = attendanceLeaveDtos.stream().mapToDouble(a -> {
|
| | | if (a.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) {
|
| | | return a.getLeaveDuration();
|
| | | } else if (a.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
|
| | | return a.getLeaveDuration() * 8;
|
| | | }
|
| | | return 0.0;
|
| | | }).sum();
|
| | | returnData.put("leaveTimeHours", BigDecimal.valueOf(leaveTimeHours).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
| | |
|
| | | LocalDateTime targetDateTime = yearMonth.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().withDayOfMonth(1).atStartOfDay();
|
| | |
|
| | | // 换休剩余时长
|
| | | Double overTime = attendanceLeaveService.getOverTimeLength(userId);
|
| | | Double overTime = attendanceLeaveService.getOverTimeLength(userId, targetDateTime);
|
| | | returnData.put("overTime", overTime);
|
| | |
|
| | | // 待结算换休时长
|
| | | Double overTimeClose = attendanceLeaveService.getOverTimeCloseLength(userId);
|
| | | // 待结算(下月即将结算)换休时长
|
| | | Double overTimeClose = attendanceLeaveService.getOverTimeCloseLength(userId, targetDateTime);
|
| | | returnData.put("overTimeClose", overTimeClose);
|
| | |
|
| | | // 本月结算换休时长
|
| | | Double overTimeCurrentClose = attendanceLeaveService.getOverTimeCurrentCloseLength(userId, targetDateTime);
|
| | | returnData.put("overTimeCurrentClose", overTimeCurrentClose);
|
| | |
|
| | | // 出差天数
|
| | | returnData.put("businessDays", attendanceBusinessTravelList.stream().filter(attendanceBusinessTravel -> attendanceBusinessTravel.getCategory().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)).count());
|
| | | returnData.put("localDays", attendanceBusinessTravelList.stream().filter(attendanceBusinessTravel -> attendanceBusinessTravel.getCategory().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)).count());
|
| | | returnData.put("businessDays", attendanceBusinessTravelList.stream().filter(attendanceBusinessTravel -> attendanceBusinessTravel.getCategory().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL) && attendanceBusinessTravel.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE)).collect(Collectors.toList()).stream().map(AttendanceBusinessTravel::getTravelDuration).reduce(0.0, Double::sum));
|
| | | returnData.put("localDays", attendanceBusinessTravelList.stream().filter(attendanceBusinessTravel -> attendanceBusinessTravel.getCategory().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE) && attendanceBusinessTravel.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE)).collect(Collectors.toList()).stream().map(AttendanceBusinessTravel::getTravelDuration).reduce(0.0, Double::sum));
|
| | |
|
| | | return returnData;
|
| | | }
|
| | |
| | | port: ${REDIS_PORT:6379}
|
| | | password: ${REDIS_PWD:}
|
| | | timeout: 5000
|
| | |
|
| | | # max-active: 50
|
| | | # max-idle: 20
|
| | | # max-wait-millis: 1000
|
| | | # min-idle: 10
|
| | |
| | |
|
| | | @Test
|
| | | public void test100() throws ParseException {
|
| | | System.out.println(attendanceLeaveService.getOverTimeLength(60L));
|
| | | System.out.println(attendanceLeaveService.getOverTimeLength(60L, LocalDateTime.now()));
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, calcTimeLength, approve } |
| | | export function allConsumedDeduction() { |
| | | return request({ |
| | | url: 'api/overtimeConsumedRecord/allConsumedDeduction', |
| | | method: 'post' |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, calcTimeLength, approve, allConsumedDeduction } |
| New file |
| | |
| | | <template> |
| | | <el-dialog |
| | | title="删除提示" |
| | | :visible.sync="dialogVisible" |
| | | width="800px" |
| | | :before-close="handleClose" |
| | | > |
| | | <div style="max-height: calc(80vh - 160px); overflow-y: scroll;"> |
| | | <div style="font-size: 16px; font-weight: 600; margin-bottom: 20px;">当前删除的申请使用了【企微审核】,无法在系统内删除,请根据不同操作设备参照以下步骤在【企业微信】操作撤回申请:</div> |
| | | <el-collapse v-model="activeNames" @change="handleChange"> |
| | | <el-collapse-item name="WEB"> |
| | | <template slot="title"> |
| | | <span style="font-size: 16px; font-weight: 600;">1.电脑端操作</span> |
| | | <span v-if="!activeNames.includes('WEB')" style="font-size: 12px; color: #999999; margin-left: 20px;">点击展开查看</span> |
| | | </template> |
| | | <div class="steps-image-box"> |
| | | <el-image v-for="(webImage, webIndex) in webImageList" :key="'web_image_' + webIndex" class="steps-image" :src="webImage" fit="contain" :preview-src-list="webImageList" /> |
| | | </div> |
| | | </el-collapse-item> |
| | | <el-collapse-item name="APP"> |
| | | <template slot="title"> |
| | | <span style="font-size: 16px; font-weight: 600;">2.手机端操作</span> |
| | | <span v-if="!activeNames.includes('APP')" style="font-size: 12px; color: #999999; margin-left: 20px;">点击展开查看</span> |
| | | </template> |
| | | <div class="steps-image-box"> |
| | | <el-image v-for="(appImage, appIndex) in appImageList" :key="'web_image_' + appIndex" class="steps-image" :src="appImage" fit="contain" :preview-src-list="appImageList" /> |
| | | </div> |
| | | </el-collapse-item> |
| | | </el-collapse> |
| | | </div> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button type="primary" @click="dialogVisible = false">我已知晓</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import Web1 from '@/assets/images/cp_approval_del/web/1.png' |
| | | import Web2 from '@/assets/images/cp_approval_del/web/2.png' |
| | | import Web3 from '@/assets/images/cp_approval_del/web/3.png' |
| | | import Web4 from '@/assets/images/cp_approval_del/web/4.png' |
| | | import App1 from '@/assets/images/cp_approval_del/app/1.jpg' |
| | | import App2 from '@/assets/images/cp_approval_del/app/2.jpg' |
| | | import App3 from '@/assets/images/cp_approval_del/app/3.jpg' |
| | | import App4 from '@/assets/images/cp_approval_del/app/4.jpg' |
| | | import App5 from '@/assets/images/cp_approval_del/app/5.jpg' |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | dialogVisible: false, |
| | | activeNames: [], |
| | | webImageList: [Web1, Web2, Web3, Web4], |
| | | appImageList: [App1, App2, App3, App4, App5] |
| | | } |
| | | }, |
| | | methods: { |
| | | handleOpen() { |
| | | const that = this |
| | | that.dialogVisible = true |
| | | }, |
| | | handleClose() { |
| | | const that = this |
| | | that.dialogVisible = false |
| | | }, |
| | | handleChange(val) { |
| | | const that = this |
| | | that.activeNames = val |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .steps-image-box { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | gap: 12px; |
| | | padding: 12px; |
| | | } |
| | | .steps-image { |
| | | width: 200px; |
| | | border-radius: 5px; |
| | | border: 1px solid #999999; |
| | | } |
| | | </style> |
| | |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | |
| | | <cp-approval-del-dialog ref="cpApprovalDelDialog" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import approvalLine from '@/components/ApprovalLine' |
| | | import cpApprovalDelDialog from '@/components/CpApprovalDelDialog' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { |
| | |
| | | } |
| | | export default { |
| | | name: 'AttendanceBusinessTravel', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, cpApprovalDelDialog }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ |
| | |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 钩子:删除 - 之前 |
| | | [CRUD.HOOK.beforeDelete]() { |
| | | const that = this |
| | | if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) { |
| | | that.$refs.cpApprovalDelDialog.handleOpen() |
| | | that.crud.delAllLoading = false |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | // 禁用 |
| | | disabledUser(data) { |
| | | if (this.userRolesLevelMin > this.roleLevelGenerl) { |
| | |
| | | this.form.travelEndTime = data.travelEndTime |
| | | this.form.departureCity = data.departureCity |
| | | this.form.arrivalCity = data.arrivalCity |
| | | this.form.cagtegory = data.category |
| | | this.form.category = data.category |
| | | this.form.travelDuration = data.travelDuration |
| | | this.form.durationUnit = data.durationUnit |
| | | this.form.approvalStatus = data.approvalStatus |
| | |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | |
| | | <cp-approval-del-dialog ref="cpApprovalDelDialog" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import approvalLine from '@/components/ApprovalLine' |
| | | import cpApprovalDelDialog from '@/components/CpApprovalDelDialog' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, userId: null, userName: null, approvalUserId: null, cardReplacementTime: null, cardReplacementReason: null, approvalStatus: null, approvalDescription: null, cardReplacementDistinguish: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null } |
| | | export default { |
| | | name: 'AttendanceCardreplacement', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, cpApprovalDelDialog }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | // 数据字典 |
| | | dicts: [constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS, constant.APPROVAL_SITE_TYPE], |
| | |
| | | this.form.approvalUserId = 0 |
| | | } |
| | | }, |
| | | // 钩子:删除 - 之前 |
| | | [CRUD.HOOK.beforeDelete]() { |
| | | const that = this |
| | | if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) { |
| | | that.$refs.cpApprovalDelDialog.handleOpen() |
| | | that.crud.delAllLoading = false |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | // 禁用 |
| | | disabledUser(data) { |
| | | if (this.userRolesLevelMin > this.roleLevelGenerl) { |
| | |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | |
| | | <cp-approval-del-dialog ref="cpApprovalDelDialog" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import approvalLine from '@/components/ApprovalLine' |
| | | import cpApprovalDelDialog from '@/components/CpApprovalDelDialog' |
| | | import constant from '@/utils/constant' |
| | | |
| | | const defaultForm = { |
| | |
| | | } |
| | | export default { |
| | | name: 'AttendanceGoOut', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, cpApprovalDelDialog }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ |
| | |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 钩子:删除 - 之前 |
| | | [CRUD.HOOK.beforeDelete]() { |
| | | const that = this |
| | | if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) { |
| | | that.$refs.cpApprovalDelDialog.handleOpen() |
| | | that.crud.delAllLoading = false |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | // 禁用 |
| | | disabledUser(data) { |
| | | if (this.userRolesLevelMin > this.roleLevelGenerl) { |
| | |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | |
| | | <cp-approval-del-dialog ref="cpApprovalDelDialog" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import approvalLine from '@/components/ApprovalLine' |
| | | import cpApprovalDelDialog from '@/components/CpApprovalDelDialog' |
| | | import constant from '@/utils/constant' |
| | | |
| | | const defaultForm = { id: null, userId: null, approvalUserId: null, leaveType: null, leaveStartTime: null, leaveEndTime: null, leaveDuration: null, leaveDurationUnit: null, leaveReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null } |
| | | export default { |
| | | name: 'AttendanceLeave', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, cpApprovalDelDialog }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '请假记录', url: 'api/attendanceLeave', idField: 'id', sort: 'leaveStartTime,desc', crudMethod: { ...crudAttendanceLeave }}) |
| | |
| | | dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR, |
| | | dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY, |
| | | dictApprovalSiteType: constant.APPROVAL_SITE_TYPE, |
| | | yearTimeLenght: null, |
| | | OverTimeLenght: null, |
| | | // 年假余额 |
| | | yearTimeLength: null, |
| | | // 调休假余额 |
| | | overTimeLength: null, |
| | | makeUpCardVisible: false, |
| | | successLoading: false, |
| | | userRolesLevelMin: null, |
| | |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 钩子:删除 - 之前 |
| | | [CRUD.HOOK.beforeDelete]() { |
| | | const that = this |
| | | if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) { |
| | | that.$refs.cpApprovalDelDialog.handleOpen() |
| | | that.crud.delAllLoading = false |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | // 钩子:在编辑之前执行 |
| | | // [CRUD.HOOK.beforeToEdit]() { |
| | | // this.getUserTimes() |
| | |
| | | } |
| | | // 获取年假剩余时长 |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 4)).then(res => { |
| | | this.yearTimeLenght = res |
| | | this.yearTimeLength = res |
| | | }) |
| | | // 获取调休假剩余时长 |
| | | crudAttendanceLeave.getOverTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 7)).then(res => { |
| | | this.OverTimeLenght = res |
| | | this.overTimeLength = res |
| | | }) |
| | | // 通过后台计算时长 |
| | | var data = JSON.stringify({ |
| | |
| | | }) |
| | | crudAttendanceLeave.calcTimeLength(data).then(res => { |
| | | // 年假和计算的时长作比较 |
| | | if (this.form.leaveType === this.dictLeaveTypeAnnualLeave && this.yearTimeLenght < res.leaveDuration) { |
| | | if (this.form.leaveType === this.dictLeaveTypeAnnualLeave && this.yearTimeLength < res.leaveDuration) { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('年假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else if (this.form.leaveType === this.dictLeaveTypeReplace && this.OverTimeLenght < res.leaveDuration) { |
| | | } else if (this.form.leaveType === this.dictLeaveTypeReplace && this.overTimeLength < res.leaveDuration) { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('调休假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else { |
| | |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <crudOperation :permission="permission"> |
| | | <el-popover slot="right" v-model="consumedDeductionVisible" v-permission="permission.highLevel" placement="top" width="240" trigger="click"> |
| | | <p>本操作将重置全部调休记录,并重新整理计算调休扣除,您确定继续本次操作吗?</p> |
| | | <p style="color: red;">注:非必要不要使用</p> |
| | | <div style="text-align: right; margin: 0"> |
| | | <el-button size="mini" type="text" @click="consumedDeductionVisible = false">取消</el-button> |
| | | <el-button type="primary" size="mini" @click="toConsumedDeduction()">确定</el-button> |
| | | </div> |
| | | <el-button |
| | | slot="reference" |
| | | :loading="consumedDeductionLoading" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-circle-check" |
| | | > |
| | | 整理调休扣除 |
| | | </el-button> |
| | | </el-popover> |
| | | </crudOperation> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | |
| | | <cp-approval-del-dialog ref="cpApprovalDelDialog" /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import approvalLine from '@/components/ApprovalLine' |
| | | import cpApprovalDelDialog from '@/components/CpApprovalDelDialog' |
| | | import constant from '@/utils/constant' |
| | | import { mapGetters } from 'vuex' |
| | | |
| | | const defaultForm = { id: null, userId: null, approvalUserId: null, overtimeStartTime: null, overtimeEndTime: null, overtimeDuration: null, overtimeDurationUnit: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null } |
| | | export default { |
| | | name: 'AttendanceOvertime', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, cpApprovalDelDialog }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '考勤加班', url: 'api/attendanceOvertime', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceOvertime }}) |
| | |
| | | edit: ['admin', 'attendanceOvertime:edit'], |
| | | del: ['admin', 'attendanceOvertime:del'], |
| | | download: ['admin', 'attendanceOvertime:list'], |
| | | approve: ['admin', 'attendanceOvertime:approve'] |
| | | approve: ['admin', 'attendanceOvertime:approve'], |
| | | highLevel: ['admin', 'timing:list'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | |
| | | successLoading: false, |
| | | makeUpCardVisible: false, |
| | | // 企微审核判断 |
| | | wecomApprovalVisible: false |
| | | wecomApprovalVisible: false, |
| | | // 整理调休扣除弹窗判断 |
| | | consumedDeductionVisible: false, |
| | | consumedDeductionLoading: false |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | // 表单赋值 |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 钩子:删除 - 之前 |
| | | [CRUD.HOOK.beforeDelete]() { |
| | | const that = this |
| | | if (that.crud.selections.some(selection => selection.wecomSpNo !== null && selection.wecomSpNo !== undefined && selection.wecomSpNo !== '')) { |
| | | that.$refs.cpApprovalDelDialog.handleOpen() |
| | | that.crud.delAllLoading = false |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | | this.$message({ type: 'error', message: error.response.data.message }) |
| | | this.successLoading = false |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }) |
| | | if (this.$refs['form']) { |
| | | this.$refs['form'].resetFields() |
| | |
| | | } |
| | | this.crud.cancelCU() |
| | | this.makeUpCardVisible = false |
| | | }, |
| | | // 整理调休假扣除 |
| | | toConsumedDeduction() { |
| | | const that = this |
| | | that.consumedDeductionVisible = false |
| | | that.consumedDeductionLoading = true |
| | | that.crud.crudMethod.allConsumedDeduction().then(() => { |
| | | that.$message.success('调休假整理完成') |
| | | that.consumedDeductionLoading = false |
| | | }).catch(() => { |
| | | that.$message.error('调休假整理失败') |
| | | that.consumedDeductionLoading = false |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | <div class="card-panel-icon-wrapper icon-message"> |
| | | <svg-icon icon-class="message" class-name="card-panel-icon" /> |
| | | </div> |
| | | |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 剩余调休时长 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="userInfo.overTime" |
| | | :duration="3600" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 请假时间 |
| | | 请假时间(小时) |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 待结算调休 |
| | | 下月结算调休 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 平日加班 |
| | | 剩余调休时长 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="userInfo.overTime" |
| | | :duration="3600" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col"> |
| | | <div class="card-panel" @click="handleSetLineChartData('shoppings')"> |
| | | <div class="card-panel-icon-wrapper icon-message"> |
| | | <svg-icon icon-class="message" class-name="card-panel-icon" /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 本月结算调休 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="userInfo.overTimeCurrentClose" |
| | | :duration="3600" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 平日加班(小时) |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 出差天数 |
| | | 出差(天) |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="userInfo.businessDays" |
| | | :duration="3600" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 客户现场 |
| | | 客户现场(天) |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="userInfo.localDays" |
| | | :duration="3600" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | |
| | | this.$emit('handleSetLineChartData', type) |
| | | }, |
| | | showPerformanceDetail() { |
| | | if (this.meritWageList[2] == undefined) { |
| | | if (this.meritWageList[2] === undefined) { |
| | | setTimeout(() => { |
| | | this.showPerformanceDetailo() |
| | | }, 3500) |
| | |
| | | <template> |
| | | <div class="dashboard-container"> |
| | | <div class="dashboard-editor-container"> |
| | | <div v-loading="loading" class="dashboard-editor-container"> |
| | | <panel-group |
| | | :user-info="userInfo" |
| | | :merit-wage-list="meritWageList" |
| | |
| | | userInfo: {}, |
| | | meritWageList: [], |
| | | // 年月 |
| | | yearMonth: new Date() |
| | | yearMonth: new Date(), |
| | | loading: false |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | }, |
| | | // 箭头点击事件 |
| | | monthClick(type) { |
| | | this.loading = true |
| | | const calendarApi = this.$refs['fullCalendar'].getApi() |
| | | if (type === 'prev') { |
| | | calendarApi.prev() |
| | |
| | | }) |
| | | .catch(() => { |
| | | this.calendarOptions.events = [] |
| | | this.loading = false |
| | | }) |
| | | .finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }, |
| | | // 日期点击 |
| | |
| | | <el-form-item label="加班工资" prop="overtimeAllowance"> |
| | | <el-input v-model="form.overtimeAllowance" style="width: 523px;" :disabled="disabledFlagByApprove" @change="statisticalAmount" /> |
| | | </el-form-item> |
| | | <el-form-item label="调休结算工资" prop="comptimeAllowance"> |
| | | <el-input v-model="form.comptimeAllowance" style="width: 523px;" :disabled="disabledFlagByApprove" @change="statisticalAmount" /> |
| | | </el-form-item> |
| | | <el-divider>公积金</el-divider> |
| | | <el-form-item label="基数" prop="accumulationFund"> |
| | | <el-input v-model="form.accumulationFund" style="width: 523px;" :disabled="disabledFlagByApprove" @change="accumulationParameterBlur" /> |
| | |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="pieceRate" label="其他补助" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney((scope.row.pieceRate == null ? 0 : scope.row.pieceRate) + (scope.row.travelAllowance == null ? 0 : scope.row.travelAllowance) + (scope.row.overtimeAllowance == null ? 0 : scope.row.overtimeAllowance)) }} |
| | | {{ crud.toMoney((scope.row.pieceRate == null ? 0 : scope.row.pieceRate) + (scope.row.travelAllowance == null ? 0 : scope.row.travelAllowance) + (scope.row.overtimeAllowance == null ? 0 : scope.row.overtimeAllowance) + (scope.row.comptimeAllowance == null ? 0 : scope.row.comptimeAllowance)) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="preTaxAmount" label="税前金额" width="100"> |
| | |
| | | import constant from '../../../utils/constant' |
| | | import crudUser from '@/api/system/user' |
| | | |
| | | const defaultForm = { id: null, userId: null, salaryYearMonth: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: 0, CompletedAchievementsRate: 0, meritMoney: 0, actualAchievementsWage: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, pieceRate: 0, travelAllowance: 0, overtimeAllowance: 0, accumulationFund: null, accumulationFundPersonal: null, accumulationFundPersonalAmount: null, accumulationFundCompany: null, accumulationFundCompanyAmount: null, retirementInsurance: null, retirementInsurancePersonal: null, retirementInsurancePersonalAmount: null, retirementInsuranceCompany: null, retirementInsuranceCompanyAmount: null, medicalInsurance: null, medicalInsurancePersonal: null, medicalInsurancePersonalAmount: null, medicalInsuranceCompany: null, medicalInsuranceCompanyAmount: null, unemploymentInsurance: null, unemploymentInsurancePersonal: null, unemploymentInsurancePersonalAmount: null, unemploymentInsuranceCompany: null, unemploymentInsuranceCompanyAmount: null, birthInsurance: null, birthInsurancePersonal: null, birthInsurancePersonalAmount: null, birthInsuranceCompany: null, birthInsuranceCompanyAmount: null, employmentInsurance: null, employmentInsurancePersonal: null, employmentInsurancePersonalAmount: null, employmentInsuranceCompany: null, employmentInsuranceCompanyAmount: null, preTaxAmount: null, individualIncomeTax: null, afterTaxAmount: null, remarks: null, publicityStatus: constant.PUBLICITY_STATUS_NOT, approveStatus: constant.APPROVE_STATUS_UNRECOGNIZED, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | const defaultForm = { id: null, userId: null, salaryYearMonth: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: 0, CompletedAchievementsRate: 0, meritMoney: 0, actualAchievementsWage: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, pieceRate: 0, travelAllowance: 0, overtimeAllowance: 0, comptimeAllowance: 0, accumulationFund: null, accumulationFundPersonal: null, accumulationFundPersonalAmount: null, accumulationFundCompany: null, accumulationFundCompanyAmount: null, retirementInsurance: null, retirementInsurancePersonal: null, retirementInsurancePersonalAmount: null, retirementInsuranceCompany: null, retirementInsuranceCompanyAmount: null, medicalInsurance: null, medicalInsurancePersonal: null, medicalInsurancePersonalAmount: null, medicalInsuranceCompany: null, medicalInsuranceCompanyAmount: null, unemploymentInsurance: null, unemploymentInsurancePersonal: null, unemploymentInsurancePersonalAmount: null, unemploymentInsuranceCompany: null, unemploymentInsuranceCompanyAmount: null, birthInsurance: null, birthInsurancePersonal: null, birthInsurancePersonalAmount: null, birthInsuranceCompany: null, birthInsuranceCompanyAmount: null, employmentInsurance: null, employmentInsurancePersonal: null, employmentInsurancePersonalAmount: null, employmentInsuranceCompany: null, employmentInsuranceCompanyAmount: null, preTaxAmount: null, individualIncomeTax: null, afterTaxAmount: null, remarks: null, publicityStatus: constant.PUBLICITY_STATUS_NOT, approveStatus: constant.APPROVE_STATUS_UNRECOGNIZED, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'NewSalary', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | |
| | | travelAllowanceRandom: 0, |
| | | // 加班工资随机数 |
| | | overtimeAllowanceRandom: 0, |
| | | // 调休结算工资随机数 |
| | | comptimeAllowanceRandom: 0, |
| | | // 公积金基数随机数 |
| | | accumulationFundRandom: 0, |
| | | // 公积金个人缴纳金额随机数 |
| | |
| | | // this.travelAllowanceRandom = Math.random() |
| | | // // 加班工资 |
| | | // this.overtimeAllowanceRandom = Math.random() |
| | | // // 调休结算工资 |
| | | // this.comptimeAllowanceRandom = Math.random() |
| | | // 个人所得税随机数 |
| | | // this.individualIncomeTaxRandom = Math.random() |
| | | this.individualIncomeTaxRandom = 0 |
| | |
| | | // 统计金额 |
| | | statisticalAmount() { |
| | | // 税前金额 |
| | | this.form.preTaxAmount = Number(this.form.actualBasicWage) + Number(this.form.actualAchievementsWage) + Number(this.form.actualPerformanceWage) + Number(this.form.actualTeamWage) + Number(this.form.pieceRate) + Number(this.form.travelAllowance) + Number(this.form.meritMoney) + Number(this.form.overtimeAllowance) |
| | | this.form.preTaxAmount = Number(this.form.actualBasicWage) + Number(this.form.actualAchievementsWage) + Number(this.form.actualPerformanceWage) + Number(this.form.actualTeamWage) + Number(this.form.pieceRate) + Number(this.form.travelAllowance) + Number(this.form.meritMoney) + Number(this.form.overtimeAllowance) + Number(this.form.comptimeAllowance) |
| | | // 税前金额随机数 |
| | | this.preTaxAmountRandom = Math.random() |
| | | // 税前金额变更 |