Merge branch 'zhaoss' of http://192.168.1.110:5678/r/pms-upgrade into master
10 files added
8 files modified
| 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.system.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.math.BigDecimal; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="sys_user_level_wage") |
| | | public class SysUserLevelWage extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`user_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "用户ID") |
| | | private Long userId; |
| | | |
| | | @Column(name = "`level_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "级别ID") |
| | | private Long levelId; |
| | | |
| | | @Column(name = "`start_date`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "开始日期") |
| | | private Timestamp startDate; |
| | | |
| | | @Column(name = "`end_date`") |
| | | @ApiModelProperty(value = "结束日期") |
| | | private Timestamp endDate; |
| | | |
| | | @Column(name = "`level_wage`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "级别工资") |
| | | private BigDecimal levelWage; |
| | | |
| | | @Column(name = "`basic_wage_proportion`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "基本工资比例") |
| | | private Double basicWageProportion; |
| | | |
| | | @Column(name = "`achievements_wage_proportion`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "绩效工资比例") |
| | | private Double achievementsWageProportion; |
| | | |
| | | @Column(name = "`performance_wage_proportion`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "业绩工资比例") |
| | | private Double performanceWageProportion; |
| | | |
| | | @Column(name = "`team_wage_proportion`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "团队工资比例") |
| | | private Double teamWageProportion; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(SysUserLevelWage source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty(value = "排班") |
| | | private SysRostering sysRostering; |
| | | |
| | | @NotBlank |
| | | @JoinColumn(name = "level_id") |
| | | @ApiModelProperty(value = "级别ID") |
| | | private Long levelId; |
| | | |
| | | @ApiModelProperty(value = "用户性别") |
| | | private String gender; |
| | | |
| 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.system.repository; |
| | | |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | 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 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | public interface SysUserLevelWageRepository extends JpaRepository<SysUserLevelWage, Long>, JpaSpecificationExecutor<SysUserLevelWage> { |
| | | |
| | | /** |
| | | * 根据用户ID查询最新记录 |
| | | * @param userId / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT * FROM sys_user_level_wage WHERE user_id = ?1 ORDER BY start_date DESC, create_time DESC LIMIT 1", nativeQuery = true) |
| | | SysUserLevelWage findLastByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据级别查询 |
| | | * @param ids / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT count(1) FROM sys_user_level_wage WHERE level_id IN ?1", nativeQuery = true) |
| | | int countByLevels(Long[] ids); |
| | | } |
| | |
| | | */ |
| | | @Query(value = "SELECT count(1) FROM sys_user WHERE rostering_id IN ?1", nativeQuery = true) |
| | | int countByRosterings(Long[] ids); |
| | | |
| | | /** |
| | | * 根据级别查询 |
| | | * @param ids / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT count(1) FROM sys_user WHERE level_id IN ?1", nativeQuery = true) |
| | | int countByLevels(Long[] ids); |
| | | } |
| | |
| | | @ApiOperation("删除级别") |
| | | @PreAuthorize("@el.check('sysLevel:del')") |
| | | public ResponseEntity<Object> deleteSysLevel(@RequestBody Long[] ids) { |
| | | // 验证是否被用户关联 |
| | | sysLevelService.verification(ids); |
| | | sysLevelService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| 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.system.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | import me.zhengjie.modules.system.service.SysUserLevelWageService; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageQueryCriteria; |
| | | 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 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "用户级别工资管理") |
| | | @RequestMapping("/api/sysUserLevelWage") |
| | | public class SysUserLevelWageController { |
| | | |
| | | private final SysUserLevelWageService sysUserLevelWageService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:download')") |
| | | public void exportSysUserLevelWage(HttpServletResponse response, SysUserLevelWageQueryCriteria criteria) throws IOException { |
| | | sysUserLevelWageService.download(sysUserLevelWageService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询用户级别工资") |
| | | @ApiOperation("查询用户级别工资") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:list')") |
| | | public ResponseEntity<Object> querySysUserLevelWage(SysUserLevelWageQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(sysUserLevelWageService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询用户级别工资") |
| | | @ApiOperation("查询用户级别工资") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:list')") |
| | | public ResponseEntity<Object> querySysUserLevelWage(SysUserLevelWageQueryCriteria criteria){ |
| | | return new ResponseEntity<>(sysUserLevelWageService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增用户级别工资") |
| | | @ApiOperation("新增用户级别工资") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:add')") |
| | | public ResponseEntity<Object> createSysUserLevelWage(@Validated @RequestBody SysUserLevelWage resources) throws Exception{ |
| | | return new ResponseEntity<>(sysUserLevelWageService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改用户级别工资") |
| | | @ApiOperation("修改用户级别工资") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:edit')") |
| | | public ResponseEntity<Object> updateSysUserLevelWage(@Validated @RequestBody SysUserLevelWage resources) throws Exception{ |
| | | sysUserLevelWageService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除用户级别工资") |
| | | @ApiOperation("删除用户级别工资") |
| | | @PreAuthorize("@el.check('sysUserLevelWage:del')") |
| | | public ResponseEntity<Object> deleteSysUserLevelWage(@RequestBody Long[] ids) { |
| | | sysUserLevelWageService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.Set; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<SysLevelDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | /** |
| | | * 验证是否被用户关联 |
| | | * @param ids / |
| | | */ |
| | | void verification(Long[] ids); |
| | | } |
| 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.system.service; |
| | | |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageDto; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | public interface SysUserLevelWageService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(SysUserLevelWageQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<SysUserLevelWageDto> |
| | | */ |
| | | List<SysUserLevelWageDto> queryAll(SysUserLevelWageQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return SysUserLevelWageDto |
| | | */ |
| | | SysUserLevelWageDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return SysUserLevelWageDto |
| | | */ |
| | | SysUserLevelWageDto create(SysUserLevelWage resources) throws Exception; |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(SysUserLevelWage resources) throws Exception; |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<SysUserLevelWageDto> all, HttpServletResponse response) throws IOException; |
| | | } |
| 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.system.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.math.BigDecimal; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @Data |
| | | public class SysUserLevelWageDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 用户ID */ |
| | | private Long userId; |
| | | |
| | | /** 级别ID */ |
| | | private Long levelId; |
| | | |
| | | /** 开始日期 */ |
| | | private Timestamp startDate; |
| | | |
| | | /** 结束日期 */ |
| | | private Timestamp endDate; |
| | | |
| | | /** 级别工资 */ |
| | | private BigDecimal levelWage; |
| | | |
| | | /** 基本工资比例 */ |
| | | private Double basicWageProportion; |
| | | |
| | | /** 绩效工资比例 */ |
| | | private Double achievementsWageProportion; |
| | | |
| | | /** 业绩工资比例 */ |
| | | private Double performanceWageProportion; |
| | | |
| | | /** 团队工资比例 */ |
| | | private Double teamWageProportion; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 用户昵称 */ |
| | | private String userNickName; |
| | | |
| | | /** 级别名称 */ |
| | | private String levelName; |
| | | } |
| 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.system.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @Data |
| | | public class SysUserLevelWageQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long userId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long levelId; |
| | | } |
| | |
| | | |
| | | private SysRosteringDto sysRostering; |
| | | |
| | | private Long levelId; |
| | | |
| | | private String gender; |
| | | |
| | | private String avatarName; |
| | |
| | | */ |
| | | package me.zhengjie.modules.system.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.system.domain.Job; |
| | | import me.zhengjie.modules.system.domain.SysLevel; |
| | | import me.zhengjie.modules.system.repository.JobRepository; |
| | | import me.zhengjie.modules.system.repository.SysUserLevelWageRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | |
| | | private final SysLevelRepository sysLevelRepository; |
| | | private final SysLevelMapper sysLevelMapper; |
| | | private final JobRepository jobRepository; |
| | | private final UserRepository userRepository; |
| | | private final SysUserLevelWageRepository sysUserLevelWageRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(SysLevelQueryCriteria criteria, Pageable pageable){ |
| | |
| | | public void download(List<SysLevelDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (SysLevelDto sysLevel : all) { |
| | | String jobName = sysLevel.getJobId() != null ? jobRepository.findById(sysLevel.getJobId()).orElseGet(Job::new).getName() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("岗位ID", sysLevel.getJobId()); |
| | | map.put("岗位名称", jobName); |
| | | map.put("名称", sysLevel.getName()); |
| | | map.put("描述", sysLevel.getDescription()); |
| | | map.put("级别工资", sysLevel.getLevelWage()); |
| | | map.put("基本工资比例", sysLevel.getBasicWageProportion()); |
| | | map.put("绩效工资比例", sysLevel.getAchievementsWageProportion()); |
| | | map.put("业绩工资比例", sysLevel.getPerformanceWageProportion()); |
| | | map.put("团队工资比例", sysLevel.getTeamWageProportion()); |
| | | map.put("基本工资比例", sysLevel.getBasicWageProportion() + "%"); |
| | | map.put("绩效工资比例", sysLevel.getAchievementsWageProportion() + "%"); |
| | | map.put("业绩工资比例", sysLevel.getPerformanceWageProportion() + "%"); |
| | | map.put("团队工资比例", sysLevel.getTeamWageProportion() + "%"); |
| | | map.put("公积金基数", sysLevel.getAccumulationRadix()); |
| | | map.put("公积金个人缴纳比例", sysLevel.getAccumulationPersonalProportion()); |
| | | map.put("公积金公司缴纳比例", sysLevel.getAccumulationCompanyProportion()); |
| | | map.put("公积金个人缴纳比例", sysLevel.getAccumulationPersonalProportion() + "%"); |
| | | map.put("公积金公司缴纳比例", sysLevel.getAccumulationCompanyProportion() + "%"); |
| | | map.put("养老险基数", sysLevel.getPensionRadix()); |
| | | map.put("养老险个人缴纳比例", sysLevel.getPensionPersonalProportion()); |
| | | map.put("养老险公司缴纳比例", sysLevel.getPensionCompanyProportion()); |
| | | map.put("养老险个人缴纳比例", sysLevel.getPensionPersonalProportion() + "%"); |
| | | map.put("养老险公司缴纳比例", sysLevel.getPensionCompanyProportion() + "%"); |
| | | map.put("医疗险基数", sysLevel.getMedicalRadix()); |
| | | map.put("医疗险个人缴纳比例", sysLevel.getMedicalPersonalProportion()); |
| | | map.put("医疗险公司缴纳比例", sysLevel.getMedicalCompanyProportion()); |
| | | map.put("医疗险个人缴纳比例", sysLevel.getMedicalPersonalProportion() + "%"); |
| | | map.put("医疗险公司缴纳比例", sysLevel.getMedicalCompanyProportion() + "%"); |
| | | map.put("失业险基数", sysLevel.getUnemploymentRadix()); |
| | | map.put("失业险个人缴纳比例", sysLevel.getUnemploymentPersonalProportion()); |
| | | map.put("失业险公司缴纳比例", sysLevel.getUnemploymentCompanyProportion()); |
| | | map.put("失业险个人缴纳比例", sysLevel.getUnemploymentPersonalProportion() + "%"); |
| | | map.put("失业险公司缴纳比例", sysLevel.getUnemploymentCompanyProportion() + "%"); |
| | | map.put("生育险基数", sysLevel.getMaternityRadix()); |
| | | map.put("生育险个人缴纳比例", sysLevel.getMaternityPersonalProportion()); |
| | | map.put("生育险公司缴纳比例", sysLevel.getMaternityCompanyProportion()); |
| | | map.put("生育险个人缴纳比例", sysLevel.getMaternityPersonalProportion() + "%"); |
| | | map.put("生育险公司缴纳比例", sysLevel.getMaternityCompanyProportion() + "%"); |
| | | map.put("工伤险基数", sysLevel.getIndustrialInjuryRadix()); |
| | | map.put("工伤险个人缴纳比例", sysLevel.getIndustrialInjuryPersonalProportion()); |
| | | map.put("工伤险公司缴纳比例", sysLevel.getIndustrialInjuryCompanyProportion()); |
| | | map.put("个人业绩比例", sysLevel.getPersonalPerformanceProportion()); |
| | | map.put("年假天数", sysLevel.getAnnualLeaveDays()); |
| | | map.put("工伤险个人缴纳比例", sysLevel.getIndustrialInjuryPersonalProportion() + "%"); |
| | | map.put("工伤险公司缴纳比例", sysLevel.getIndustrialInjuryCompanyProportion() + "%"); |
| | | map.put("个人业绩比例", sysLevel.getPersonalPerformanceProportion() + "%"); |
| | | map.put("年假天数", sysLevel.getAnnualLeaveDays() + "天"); |
| | | map.put("备注", sysLevel.getRemarks()); |
| | | map.put("创建者", sysLevel.getCreateBy()); |
| | | map.put("创建时间", sysLevel.getCreateTime()); |
| | |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | @Override |
| | | public void verification(Long[] ids) { |
| | | if(userRepository.countByLevels(ids) > 0){ |
| | | throw new BadRequestException("所选的级别中存在用户关联,请解除关联再试!"); |
| | | } |
| | | if(sysUserLevelWageRepository.countByLevels(ids) > 0){ |
| | | throw new BadRequestException("所选的级别中存在用户级别工资关联,请解除关联再试!"); |
| | | } |
| | | } |
| | | } |
| 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.system.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.system.domain.SysLevel; |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysLevelRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.system.repository.SysUserLevelWageRepository; |
| | | import me.zhengjie.modules.system.service.SysUserLevelWageService; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageDto; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageQueryCriteria; |
| | | import me.zhengjie.modules.system.service.mapstruct.SysUserLevelWageMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class SysUserLevelWageServiceImpl implements SysUserLevelWageService { |
| | | |
| | | private final SysUserLevelWageRepository sysUserLevelWageRepository; |
| | | private final SysUserLevelWageMapper sysUserLevelWageMapper; |
| | | private final UserRepository userRepository; |
| | | private final SysLevelRepository sysLevelRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(SysUserLevelWageQueryCriteria criteria, Pageable pageable){ |
| | | Page<SysUserLevelWage> page = sysUserLevelWageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<SysUserLevelWage, SysUserLevelWageDto> func = new Function<SysUserLevelWage, SysUserLevelWageDto>(){ |
| | | @Override |
| | | public SysUserLevelWageDto apply(SysUserLevelWage t) { |
| | | // 将实体类转换成DTO |
| | | SysUserLevelWageDto sysUserLevelWageDto = sysUserLevelWageMapper.toDto(t); |
| | | // 根据用户ID查询用户信息 |
| | | User user = userRepository.findById(sysUserLevelWageDto.getUserId()).orElseGet(User::new); |
| | | ValidationUtil.isNull(user.getId(),"User","id",sysUserLevelWageDto.getUserId()); |
| | | // 用户昵称 |
| | | sysUserLevelWageDto.setUserNickName(user.getNickName()); |
| | | // 根据级别ID查询级别信息 |
| | | SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelWageDto.getLevelId()).orElseGet(SysLevel::new); |
| | | ValidationUtil.isNull(sysLevel.getId(),"SysLevel","id",sysUserLevelWageDto.getLevelId()); |
| | | // 级别名称 |
| | | sysUserLevelWageDto.setLevelName(sysLevel.getName()); |
| | | // 返回处理好的DTO |
| | | return sysUserLevelWageDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUserLevelWageDto> queryAll(SysUserLevelWageQueryCriteria criteria){ |
| | | return sysUserLevelWageMapper.toDto(sysUserLevelWageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public SysUserLevelWageDto findById(Long id) { |
| | | SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findById(id).orElseGet(SysUserLevelWage::new); |
| | | ValidationUtil.isNull(sysUserLevelWage.getId(),"SysUserLevelWage","id",id); |
| | | return sysUserLevelWageMapper.toDto(sysUserLevelWage); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public SysUserLevelWageDto create(SysUserLevelWage resources) throws Exception { |
| | | // 查询旧用户级别工资 |
| | | SysUserLevelWage oldSysUserLevelWage = selectOldUserLevelWage(resources.getUserId()); |
| | | // 判断旧用户级别工资是否为空 |
| | | if (oldSysUserLevelWage != null) { |
| | | // 旧日期字符串 |
| | | String oldDateString = oldSysUserLevelWage.getStartDate().toString().substring(0,10); |
| | | // 新日期字符串 |
| | | String newDateString = resources.getStartDate().toString().substring(0,10); |
| | | // 判断新、旧日期字符串 |
| | | if (oldDateString.equals(newDateString)) { |
| | | throw new BadRequestException("每天只能调整一次用户级别工资,请更换日期再试!"); |
| | | } |
| | | if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) { |
| | | throw new BadRequestException("日期必须大于最新用户级别工资日期,请更换日期再试!"); |
| | | } |
| | | // 创建Calendar实例 |
| | | Calendar previousCalendar = Calendar.getInstance(); |
| | | // 设置新日期时间 |
| | | previousCalendar.setTime(resources.getStartDate()); |
| | | // 设置前一天时间 |
| | | previousCalendar.add(Calendar.DATE, -1); |
| | | // 旧用户级别工资 |
| | | oldSysUserLevelWage.setEndDate(new Timestamp(previousCalendar.getTime().getTime())); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(oldSysUserLevelWage); |
| | | } |
| | | // 保存 |
| | | return sysUserLevelWageMapper.toDto(sysUserLevelWageRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(SysUserLevelWage resources) throws Exception { |
| | | // 查询旧用户级别工资 |
| | | SysUserLevelWage oldSysUserLevelWage = selectOldUserLevelWage(resources.getUserId()); |
| | | // 判断旧用户级别工资是否为空 |
| | | if (oldSysUserLevelWage != null) { |
| | | // 判断修改的是否是最新履历 |
| | | if (oldSysUserLevelWage.getId() != resources.getId()) { |
| | | throw new BadRequestException("旧用户级别工资无法进行修改,请选择最新用户级别工资再试!"); |
| | | } |
| | | // 旧日期字符串 |
| | | String oldDateString = oldSysUserLevelWage.getStartDate().toString().substring(0,10); |
| | | // 获取当前日期 |
| | | Date nowDate = new Date(); |
| | | // 创建Calendar实例 |
| | | Calendar nowCalendar = Calendar.getInstance(); |
| | | // 设置当前时间 |
| | | nowCalendar.setTime(nowDate); |
| | | // 新日期字符串 |
| | | String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10); |
| | | // 判断新、旧日期字符串 |
| | | if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) { |
| | | // 复制 |
| | | oldSysUserLevelWage.copy(resources); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(oldSysUserLevelWage); |
| | | } else { |
| | | // 新用户级别工资 |
| | | resources.setId(null); |
| | | resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(resources); |
| | | // 设置前一天时间 |
| | | nowCalendar.add(Calendar.DATE, -1); |
| | | // 旧用户级别工资 |
| | | oldSysUserLevelWage.setEndDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(oldSysUserLevelWage); |
| | | } |
| | | } else { |
| | | throw new BadRequestException("未找到最新用户级别工资,请稍后再试!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | sysUserLevelWageRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<SysUserLevelWageDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (SysUserLevelWageDto sysUserLevelWage : all) { |
| | | String nickName = sysUserLevelWage.getUserId() != null ? userRepository.findById(sysUserLevelWage.getUserId()).orElseGet(User::new).getNickName() : ""; |
| | | String levelName = sysUserLevelWage.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelWage.getLevelId()).orElseGet(SysLevel::new).getName() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户昵称", nickName); |
| | | map.put("级别名称", levelName); |
| | | map.put("开始日期", sysUserLevelWage.getStartDate()); |
| | | map.put("结束日期", sysUserLevelWage.getEndDate()); |
| | | map.put("级别工资", sysUserLevelWage.getLevelWage()); |
| | | map.put("基本工资比例", sysUserLevelWage.getBasicWageProportion()); |
| | | map.put("绩效工资比例", sysUserLevelWage.getAchievementsWageProportion()); |
| | | map.put("业绩工资比例", sysUserLevelWage.getPerformanceWageProportion()); |
| | | map.put("团队工资比例", sysUserLevelWage.getTeamWageProportion()); |
| | | map.put("备注", sysUserLevelWage.getRemarks()); |
| | | map.put("创建者", sysUserLevelWage.getCreateBy()); |
| | | map.put("创建时间", sysUserLevelWage.getCreateTime()); |
| | | map.put("更新者", sysUserLevelWage.getUpdateBy()); |
| | | map.put("更新时间", sysUserLevelWage.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | /** |
| | | * 查询旧用户级别工资 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | private SysUserLevelWage selectOldUserLevelWage(Long userId) { |
| | | // 旧用户级别工资 |
| | | SysUserLevelWage oldSysUserLevelWage = sysUserLevelWageRepository.findLastByUserId(userId); |
| | | // 判断旧用户级别工资是否为空 |
| | | if (oldSysUserLevelWage != null && oldSysUserLevelWage.getId() != null) { |
| | | return oldSysUserLevelWage; |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.security.service.OnlineUserService; |
| | | import me.zhengjie.modules.security.service.UserCacheManager; |
| | | import me.zhengjie.modules.system.domain.SysLevel; |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.exception.EntityExistException; |
| | | import me.zhengjie.exception.EntityNotFoundException; |
| | | import me.zhengjie.modules.system.repository.SysLevelRepository; |
| | | import me.zhengjie.modules.system.repository.SysUserLevelWageRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.system.service.UserService; |
| | | import me.zhengjie.modules.system.service.dto.*; |
| | | import me.zhengjie.modules.system.service.mapstruct.SysUserLevelWageMapper; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserMapper; |
| | | import me.zhengjie.utils.*; |
| | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.sql.Timestamp; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private final UserCacheManager userCacheManager; |
| | | private final OnlineUserService onlineUserService; |
| | | private final UserLoginMapper userLoginMapper; |
| | | private final SysLevelRepository sysLevelRepository; |
| | | private final SysUserLevelWageRepository sysUserLevelWageRepository; |
| | | |
| | | @Override |
| | | public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { |
| | |
| | | throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | } |
| | | userRepository.save(resources); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(resources.getId(), null, resources.getLevelId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(!resources.getEnabled()){ |
| | | onlineUserService.kickOutForUsername(resources.getUsername()); |
| | | } |
| | | // 临时旧用户级别ID |
| | | Long tempOldLevelId = user.getLevelId();; |
| | | user.setUsername(resources.getUsername()); |
| | | user.setEmail(resources.getEmail()); |
| | | user.setEnabled(resources.getEnabled()); |
| | |
| | | user.setAddress(resources.getAddress()); |
| | | user.setDingding(resources.getDingding()); |
| | | user.setSysRostering(resources.getSysRostering()); |
| | | user.setLevelId(resources.getLevelId()); |
| | | // 临时新用户级别ID |
| | | Long tempNewLevelId = user.getLevelId(); |
| | | userRepository.save(user); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(user.getId(), tempOldLevelId, tempNewLevelId); |
| | | // 清除缓存 |
| | | delCaches(user.getId(), user.getUsername()); |
| | | } |
| | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (UserDto userDTO : queryAll) { |
| | | List<String> roles = userDTO.getRoles().stream().map(RoleSmallDto::getName).collect(Collectors.toList()); |
| | | String levelName = userDTO.getLevelId() != null ? sysLevelRepository.findById(userDTO.getLevelId()).orElseGet(SysLevel::new).getName() : ""; |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户名", userDTO.getUsername()); |
| | | map.put("角色", roles); |
| | | map.put("部门", userDTO.getDept().getName()); |
| | | map.put("岗位", userDTO.getJobs().stream().map(JobSmallDto::getName).collect(Collectors.toList())); |
| | | map.put("邮箱", userDTO.getEmail()); |
| | | map.put("钉钉ID", userDTO.getDingding()); |
| | | map.put("排班ID", userDTO.getSysRostering().getId()); |
| | | map.put("钉钉号", userDTO.getDingding()); |
| | | map.put("排班", userDTO.getSysRostering().getName()); |
| | | map.put("级别", levelName); |
| | | map.put("状态", userDTO.getEnabled() ? "启用" : "禁用"); |
| | | map.put("手机号码", userDTO.getPhone()); |
| | | map.put("修改密码的时间", userDTO.getPwdResetTime()); |
| | |
| | | private void flushCache(String username) { |
| | | userCacheManager.cleanUserCache(username); |
| | | } |
| | | |
| | | /** |
| | | * 判断用户级别变更 |
| | | * @param userId |
| | | * @param oldLevelId |
| | | * @param newLevelId |
| | | */ |
| | | private void checkUserLevel(Long userId, Long oldLevelId, Long newLevelId) { |
| | | // 判断新旧用户级别ID是否相等 |
| | | if (oldLevelId == null) { |
| | | // 创建用户级别工资 |
| | | createSysUserLevelWage(userId, newLevelId); |
| | | } else if (oldLevelId != newLevelId) { |
| | | // 旧用户级别工资 |
| | | SysUserLevelWage oldSysUserLevelWage = sysUserLevelWageRepository.findLastByUserId(userId); |
| | | // 判断旧用户级别工资是否为空 |
| | | if (oldSysUserLevelWage != null && oldSysUserLevelWage.getId() != null) { |
| | | // 旧日期字符串 |
| | | String oldDateString = oldSysUserLevelWage.getStartDate().toString().substring(0,10); |
| | | // 获取当前日期 |
| | | Date nowDate = new Date(); |
| | | // 创建Calendar实例 |
| | | Calendar nowCalendar = Calendar.getInstance(); |
| | | // 设置当前时间 |
| | | nowCalendar.setTime(nowDate); |
| | | // 新日期字符串 |
| | | String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10); |
| | | // 判断新、旧日期字符串 |
| | | if (oldDateString.equals(nowDateString)) { |
| | | throw new BadRequestException("每天只能调整一次级别,请明日再试!"); |
| | | } |
| | | // 设置前一天时间 |
| | | nowCalendar.add(Calendar.DATE, -1); |
| | | // 旧用户级别工资 |
| | | oldSysUserLevelWage.setEndDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(oldSysUserLevelWage); |
| | | } |
| | | // 创建用户级别工资 |
| | | createSysUserLevelWage(userId, newLevelId); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建用户级别工资 |
| | | * @param userId |
| | | * @param levelId |
| | | */ |
| | | private void createSysUserLevelWage(Long userId, Long levelId) { |
| | | // 级别 |
| | | SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new); |
| | | // 用户级别工资 |
| | | SysUserLevelWage sysUserLevelWage = new SysUserLevelWage(); |
| | | sysUserLevelWage.setUserId(userId); |
| | | sysUserLevelWage.setLevelId(levelId); |
| | | sysUserLevelWage.setStartDate(new Timestamp(new Date().getTime())); |
| | | sysUserLevelWage.setLevelWage(sysLevel.getLevelWage()); |
| | | sysUserLevelWage.setBasicWageProportion(sysLevel.getBasicWageProportion()); |
| | | sysUserLevelWage.setAchievementsWageProportion(sysLevel.getAchievementsWageProportion()); |
| | | sysUserLevelWage.setPerformanceWageProportion(sysLevel.getPerformanceWageProportion()); |
| | | sysUserLevelWage.setTeamWageProportion(sysLevel.getTeamWageProportion()); |
| | | // 保存 |
| | | sysUserLevelWageRepository.save(sysUserLevelWage); |
| | | } |
| | | } |
| 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.system.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.system.domain.SysUserLevelWage; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelWageDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2022-12-19 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysUserLevelWageMapper extends BaseMapper<SysUserLevelWageDto, SysUserLevelWage> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/sysUserLevelWage/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/sysUserLevelWage', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/sysUserLevelWage/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/sysUserLevelWage', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del } |
| | |
| | | </el-select> |
| | | <rrOperation /> |
| | | </div> |
| | | <crudOperation show="" :permission="permission" /> |
| | | <crudOperation show="" :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="info" |
| | | icon="el-icon-view" |
| | | @click="toLevelWage" |
| | | > |
| | | 用户级别工资 |
| | | </el-button> |
| | | </crudOperation> |
| | | </div> |
| | | <!--表单渲染--> |
| | | <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="570px"> |
| | |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" /> |
| | | </el-form-item> |
| | | <el-form-item label="部门" prop="dept.id"> |
| | | <treeselect |
| | | v-model="form.dept.id" |
| | | :options="depts" |
| | | :load-options="loadDepts" |
| | | style="width: 178px" |
| | | placeholder="选择部门" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位" prop="jobs"> |
| | | <el-select |
| | | v-model="jobDatas" |
| | | style="width: 178px" |
| | | multiple |
| | | multiple-limit="1" |
| | | placeholder="请选择" |
| | | @remove-tag="deleteTag" |
| | | @change="changeJob" |
| | | > |
| | | <el-option |
| | | v-for="item in jobs" |
| | | :key="item.name" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="性别"> |
| | | <el-radio-group v-model="form.gender" style="width: 178px"> |
| | | <el-radio label="男">男</el-radio> |
| | |
| | | placeholder="请选择" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="住址" prop="address"> |
| | | <el-input v-model="form.address" style="width: 437px" /> |
| | | </el-form-item> |
| | | <el-form-item label="部门" prop="dept.id"> |
| | | <treeselect |
| | | v-model="form.dept.id" |
| | | :options="depts" |
| | | :load-options="loadDepts" |
| | | style="width: 178px" |
| | | placeholder="选择部门" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位" prop="jobs"> |
| | | <el-select |
| | | v-model="jobDatas" |
| | | style="width: 178px" |
| | | multiple |
| | | :multiple-limit="1" |
| | | placeholder="请选择" |
| | | @remove-tag="deleteTag" |
| | | @change="changeJob" |
| | | > |
| | | <el-option |
| | | v-for="item in jobs" |
| | | :key="item.name" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="排班" prop="sysRostering.id"> |
| | | <el-select v-model="form.sysRostering.id" clearable style="width: 178px" placeholder="请选择"> |
| | | <el-option |
| | |
| | | <el-form-item label="钉钉号" prop="dingding"> |
| | | <el-input v-model="form.dingding" /> |
| | | </el-form-item> |
| | | <el-form-item v-if="crud.status.add == crudStatusPrepared" label="级别" prop="levelId"> |
| | | <el-select v-model="form.levelId" clearable style="width: 178px" placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in levels" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.enabled" :disabled="form.id === user.id"> |
| | | <el-radio |
| | |
| | | >{{ item.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="住址" prop="address"> |
| | | <el-input v-model="form.address" style="width: 437px" /> |
| | | </el-form-item> |
| | | <el-form-item style="margin-bottom: 0;" label="角色" prop="roles"> |
| | | <el-select |
| | | v-model="roleDatas" |
| | | style="width: 437px" |
| | | multiple |
| | | multiple-limit="1" |
| | | :multiple-limit="1" |
| | | placeholder="请选择" |
| | | @remove-tag="deleteTag" |
| | | @change="changeRole" |
| | |
| | | import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
| | | import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect' |
| | | import crudRostering from '@/api/system/rostering' |
| | | import crudLevel from '@/api/system/level' |
| | | let userRoles = [] |
| | | let userJobs = [] |
| | | const defaultForm = { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }} |
| | | const defaultForm = { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null } |
| | | export default { |
| | | name: 'User', |
| | | components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker }, |
| | |
| | | 'sysRostering.id': [ |
| | | { required: true, message: '请选择排班', trigger: 'change' } |
| | | ], |
| | | levelId: [ |
| | | { required: true, message: '请选择级别', trigger: 'change' } |
| | | ], |
| | | dingding: [ |
| | | { required: true, message: '请输入钉钉号', trigger: 'blur' }, |
| | | { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' } |
| | |
| | | { min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | // 排班 |
| | | rosterings: [] |
| | | rosterings: [], |
| | | // 级别 |
| | | levels: [] |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | const job = { id: data } |
| | | userJobs.push(job) |
| | | }) |
| | | // 判断CRUD状态 |
| | | if (this.crud.status.add === this.crudStatusPrepared) { |
| | | // 获取级别 |
| | | this.getLevel() |
| | | // 用户表单 |
| | | this.form.levelId = null |
| | | } |
| | | }, |
| | | deleteTag(value) { |
| | | userRoles.forEach(function(data, index) { |
| | |
| | | _this.jobDatas.push(job.id) |
| | | const data = { id: job.id } |
| | | userJobs.push(data) |
| | | // 判断循环是否结束 |
| | | if (index === form.jobs.length - 1) { |
| | | // 获取级别 |
| | | _this.getLevel() |
| | | } |
| | | }) |
| | | }, |
| | | // 提交前做的操作 |
| | |
| | | }, |
| | | checkboxT(row, rowIndex) { |
| | | return row.id !== this.user.id |
| | | }, |
| | | // 获取级别 |
| | | getLevel() { |
| | | // 判断用户岗位列表 |
| | | if (userJobs.length !== 0) { |
| | | // 获取级别 |
| | | crudLevel.getAll({ jobId: userJobs[0].id }).then(res => { |
| | | // 级别 |
| | | this.levels = res |
| | | }) |
| | | } else { |
| | | // 级别 |
| | | this.levels = [] |
| | | } |
| | | }, |
| | | // 去用户级别工资 |
| | | toLevelWage() { |
| | | // 跳转页面 |
| | | this.$router.push({ path: '/system/sysUserLevelWage' }) |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.userId" filterable clearable placeholder="所属用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.levelId" filterable clearable placeholder="所属级别" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in levels" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <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-form-item label="所属用户" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="所属用户" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属级别" prop="levelId"> |
| | | <el-select v-model="form.levelId" filterable clearable placeholder="所属级别" style="width: 370px;" @change="levelChange"> |
| | | <el-option |
| | | v-for="item in levels" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="开始日期" prop="startDate"> |
| | | <el-date-picker v-model="form.startDate" type="date" :picker-options="startDatePickerOptions" :disabled="crud.status.edit == crudStatusPrepared" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="结束日期"> |
| | | <el-date-picker v-model="form.endDate" type="date" :picker-options="endDatePickerOptions" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="级别工资" prop="levelWage"> |
| | | <money-input :key="random" v-model="form.levelWage" :width="370" /> |
| | | </el-form-item> |
| | | <el-divider>工资比例</el-divider> |
| | | <el-form-item label="基本工资" prop="basicWageProportion"> |
| | | <el-input v-model="form.basicWageProportion" style="width: 370px;"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="绩效工资" prop="achievementsWageProportion"> |
| | | <el-input v-model="form.achievementsWageProportion" style="width: 370px;"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="业绩工资" prop="performanceWageProportion"> |
| | | <el-input v-model="form.performanceWageProportion" style="width: 370px;"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="团队工资" prop="teamWageProportion"> |
| | | <el-input v-model="form.teamWageProportion" style="width: 370px;"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 370px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" fixed="left" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userNickName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="levelName" label="所属级别" fixed="left" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.levelName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="startDate" label="开始日期" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.startDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="endDate" label="结束日期" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.endDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="levelWage" label="级别工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.levelWage) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="工资比例"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="basicWageProportion" label="基本工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.basicWageProportion }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="achievementsWageProportion" label="绩效工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.achievementsWageProportion }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="performanceWageProportion" label="业绩工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.performanceWageProportion }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="teamWageProportion" label="团队工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.teamWageProportion }}% |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column v-if="checkPer(['admin','sysUserLevelWage:edit','sysUserLevelWage:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudSysUserLevelWage from '@/api/system/userLevelWage' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import crudUser from '@/api/system/user' |
| | | import crudLevel from '@/api/system/level' |
| | | |
| | | const defaultForm = { id: null, userId: null, levelId: null, startDate: null, endDate: null, levelWage: null, basicWageProportion: null, achievementsWageProportion: null, performanceWageProportion: null, teamWageProportion: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'SysUserLevelWage', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '用户级别工资', url: 'api/sysUserLevelWage', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysUserLevelWage }}) |
| | | }, |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 工资(千万内)验证 |
| | | var wageValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) { |
| | | callback(new Error('请输入 一千万 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | // 比例(百内)验证 |
| | | var proportionValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一百 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'sysUserLevelWage:add'], |
| | | edit: ['admin', 'sysUserLevelWage:edit'], |
| | | del: ['admin', 'sysUserLevelWage:del'], |
| | | download: ['admin', 'sysUserLevelWage:download'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '所属用户不能为空', trigger: 'blur' } |
| | | ], |
| | | levelId: [ |
| | | { required: true, message: '所属级别不能为空', trigger: 'blur' } |
| | | ], |
| | | startDate: [ |
| | | { required: true, message: '开始日期不能为空', trigger: 'blur' } |
| | | ], |
| | | levelWage: [ |
| | | { required: true, message: '级别工资不能为空', trigger: 'blur' }, |
| | | { validator: wageValidate, trigger: 'blur' } |
| | | ], |
| | | basicWageProportion: [ |
| | | { required: true, message: '基本工资比例不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ], |
| | | achievementsWageProportion: [ |
| | | { required: true, message: '绩效工资比例不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ], |
| | | performanceWageProportion: [ |
| | | { required: true, message: '业绩工资比例不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ], |
| | | teamWageProportion: [ |
| | | { required: true, message: '团队工资比例不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'userId', display_name: '所属用户' }, |
| | | { key: 'levelId', display_name: '所属级别' } |
| | | ], |
| | | // 开始日期选项 |
| | | startDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.endDate != null && _this.form.endDate !== '' ? time.getTime() > _this.form.endDate : false |
| | | } |
| | | }, |
| | | // 结束日期选项 |
| | | endDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.form.startDate != null && _this.form.startDate !== '' ? time.getTime() < _this.form.startDate : false |
| | | } |
| | | }, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | // 用户列表 |
| | | users: [], |
| | | // 级别列表 |
| | | levels: [], |
| | | // 随机数 |
| | | random: 0 |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取用户 |
| | | this.getUser() |
| | | // 获取级别 |
| | | this.getLevel() |
| | | return true |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | | // 获取用户 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.users = res |
| | | }) |
| | | }, |
| | | // 获取级别 |
| | | getLevel() { |
| | | // 获取级别 |
| | | crudLevel.getAll().then(res => { |
| | | // 级别列表 |
| | | this.levels = res |
| | | }) |
| | | }, |
| | | // 钩子: 开始 "新建/编辑" - 之前 |
| | | [CRUD.HOOK.beforeToCU]() { |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 级别改变 |
| | | levelChange() { |
| | | // 循环级别列表 |
| | | for (const item in this.levels) { |
| | | // 判断级别 |
| | | if (this.levels[item].id === this.form.levelId) { |
| | | // 表单赋值 |
| | | this.form.levelWage = this.levels[item].levelWage |
| | | this.form.basicWageProportion = this.levels[item].basicWageProportion |
| | | this.form.achievementsWageProportion = this.levels[item].achievementsWageProportion |
| | | this.form.performanceWageProportion = this.levels[item].performanceWageProportion |
| | | this.form.teamWageProportion = this.levels[item].teamWageProportion |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |