diff --git a/ruans-admin/src/main/resources/application-dev.yml b/ruans-admin/src/main/resources/application-dev.yml index 9763718..2021b89 100644 --- a/ruans-admin/src/main/resources/application-dev.yml +++ b/ruans-admin/src/main/resources/application-dev.yml @@ -49,9 +49,9 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) - url: jdbc:mysql://localhost:3306/rs-vue-plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://192.168.0.155:3306/gzcxdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root - password: 1234 + password: Ycgis!2509 # type: ${spring.datasource.type} # driverClassName: org.postgresql.Driver # url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true diff --git a/ruans-admin/src/main/resources/application-prod.yml b/ruans-admin/src/main/resources/application-prod.yml index 88ce221..9f189cb 100644 --- a/ruans-admin/src/main/resources/application-prod.yml +++ b/ruans-admin/src/main/resources/application-prod.yml @@ -52,9 +52,9 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) - url: jdbc:mysql://localhost:3306/rs-vue-plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + url: jdbc:mysql://192.168.0.155:3306/gzcxdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true username: root - password: root + password: Ycgis!2509 # # 从库数据源 # slave: # lazy: true diff --git a/ruans-modules/ruans-generator/src/main/resources/generator.yml b/ruans-modules/ruans-generator/src/main/resources/generator.yml index d779d97..56230f7 100644 --- a/ruans-modules/ruans-generator/src/main/resources/generator.yml +++ b/ruans-modules/ruans-generator/src/main/resources/generator.yml @@ -3,7 +3,7 @@ gen: # 作者 author: Lion Li # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool - packageName: org.dromara.system + packageName: com.ruans.system # 自动去除表前缀,默认是false autoRemovePre: false # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/controller/BizSalaryController.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/controller/BizSalaryController.java new file mode 100644 index 0000000..681e3eb --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/controller/BizSalaryController.java @@ -0,0 +1,134 @@ +package com.ruans.biz.controller; + +import java.util.ArrayList; +import java.util.List; + +import com.ruans.common.excel.core.ExcelResult; +import com.ruans.biz.domain.vo.BizSalaryImportVo; +import com.ruans.system.listener.BizSalaryImportListener; +import com.ruans.system.listener.SysUserImportListener; +import lombok.RequiredArgsConstructor; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.*; +import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import com.ruans.common.idempotent.annotation.RepeatSubmit; +import com.ruans.common.log.annotation.Log; +import com.ruans.common.web.core.BaseController; +import com.ruans.common.mybatis.core.page.PageQuery; +import com.ruans.common.core.domain.R; +import com.ruans.common.core.validate.AddGroup; +import com.ruans.common.core.validate.EditGroup; +import com.ruans.common.log.enums.BusinessType; +import com.ruans.common.excel.utils.ExcelUtil; +import com.ruans.biz.domain.vo.BizSalaryVo; +import com.ruans.biz.domain.bo.BizSalaryBo; +import com.ruans.biz.service.IBizSalaryService; +import com.ruans.common.mybatis.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 工资明细 + * + * @author YIN + * @date 2026-03-25 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/biz/salary") +public class BizSalaryController extends BaseController { + + private final IBizSalaryService bizSalaryService; + + /** + * 查询工资明细列表 + */ + @SaCheckPermission("biz:salary:list") + @GetMapping("/list") + public TableDataInfo list(BizSalaryBo bo, PageQuery pageQuery) { + return bizSalaryService.queryPageList(bo, pageQuery); + } + + /** + * 导入数据 + * + * @param file 导入文件 + * @param updateSupport 是否更新已存在数据 + */ + @Log(title = "工资明细", businessType = BusinessType.IMPORT) + @SaCheckPermission("biz:salary:import") + @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public R importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { + ExcelResult result = ExcelUtil.importExcel(file.getInputStream(), BizSalaryImportVo.class, new BizSalaryImportListener(updateSupport)); + return R.ok(result.getAnalysis()); + } + + /** + * 获取导入模板 + */ + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) { + ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", BizSalaryImportVo.class, response); + } + + /** + * 导出工资明细列表 + */ + @SaCheckPermission("biz:salary:export") + @Log(title = "工资明细", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(BizSalaryBo bo, HttpServletResponse response) { + List list = bizSalaryService.queryList(bo); + ExcelUtil.exportExcel(list, "工资明细", BizSalaryVo.class, response); + } + + /** + * 获取工资明细详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("biz:salary:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(bizSalaryService.queryById(id)); + } + + /** + * 新增工资明细 + */ + @SaCheckPermission("biz:salary:add") + @Log(title = "工资明细", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody BizSalaryBo bo) { + return toAjax(bizSalaryService.insertByBo(bo)); + } + + /** + * 修改工资明细 + */ + @SaCheckPermission("biz:salary:edit") + @Log(title = "工资明细", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody BizSalaryBo bo) { + return toAjax(bizSalaryService.updateByBo(bo)); + } + + /** + * 删除工资明细 + * + * @param ids 主键串 + */ + @SaCheckPermission("biz:salary:remove") + @Log(title = "工资明细", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(bizSalaryService.deleteWithValidByIds(List.of(ids), true)); + } +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/BizSalary.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/BizSalary.java new file mode 100644 index 0000000..e94a7ba --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/BizSalary.java @@ -0,0 +1,196 @@ +package com.ruans.biz.domain; + +import com.baomidou.mybatisplus.annotation.*; +import com.ruans.common.mybatis.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 工资明细对象 biz_salary + * + * @author YIN + * @date 2026-03-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("biz_salary") +public class BizSalary extends BaseEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId(value = "id") + private Long id; + + /** + * 工资类型 + */ + private String salaryType; + + /** + * 用户ID + */ + private Long userId; + + /** + * 警号 + */ + private String policeNo; + + /** + * 人员姓名 + */ + private String policeName; + + /** + * 身份证号 + */ + private String idcard; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 部门ID + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 工资月份 + */ + private String yearMonth; + + /** + * 年份 + */ + private Long salaryYear; + + /** + * 月份 + */ + private Long salaryMonth; + + /** + * 职务(技术等级)工资 + */ + private Long postSalary; + + /** + * 级别(比例)工资 + */ + private Long gradeSalary; + + /** + * 生活性补贴 + */ + private Long livingSubsidy; + + /** + * 工作性津贴 + */ + private Long workAllowance; + + /** + * 基础绩效奖 + */ + private Long basicPerformance; + + /** + * 警衔津贴 + */ + private Long policeRankAllowance; + + /** + * 执勤津贴 + */ + private Long dutyAllowance; + + /** + * 加班补贴 + */ + private Long overtimePay; + + /** + * 乡镇工作津贴 + */ + private Long townshipWorkAllowance; + + /** + * 扣个人所得税 + */ + private Long individualIncomeTax; + + /** + * 扣医疗保险金 + */ + private Long medicalInsuranceFund; + + /** + * 扣住房公积金 + */ + private Long housingFund; + + /** + * 扣基本养老金 + */ + private Long basicPension; + + /** + * 扣职业年金 + */ + private Long occupationalPension; + + /** + * 其他代扣 + */ + private Long otherDeduction; + + /** + * 扣款小计 + */ + private Long totalDeduction; + + /** + * 增发 + */ + private Long increasePay; + + /** + * 减发 + */ + private Long reducePay; + + /** + * 应发 + */ + private Long totalPay; + + /** + * 实发 + */ + private Long actualSalary; + + /** + * 备注 + */ + private String remark; + + /** + * 创建用户ID + */ + private Long createUserId; + + +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/bo/BizSalaryBo.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/bo/BizSalaryBo.java new file mode 100644 index 0000000..9f2a92b --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/bo/BizSalaryBo.java @@ -0,0 +1,194 @@ +package com.ruans.biz.domain.bo; + +import com.ruans.biz.domain.BizSalary; +import com.ruans.common.core.validate.EditGroup; +import com.ruans.common.mybatis.core.domain.BaseEntity; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 工资明细业务对象 biz_salary + * + * @author YIN + * @date 2026-03-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = BizSalary.class, reverseConvertGenerate = false) +public class BizSalaryBo extends BaseEntity { + + /** + * ID + */ + @NotNull(message = "ID不能为空", groups = { EditGroup.class }) + private Long id; + + /** + * 工资类型 + */ + private String salaryType; + + /** + * 用户ID + */ + private Long userId; + + /** + * 警号 + */ + private String policeNo; + + /** + * 人员姓名 + */ + private String policeName; + + /** + * 身份证号 + */ + private String idcard; + + /** + * 银行卡号 + */ + private String bankCard; + + /** + * 部门ID + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 工资月份 + */ + private String yearMonth; + + /** + * 年份 + */ + private Long salaryYear; + + /** + * 月份 + */ + private Long salaryMonth; + + /** + * 职务(技术等级)工资 + */ + private Long postSalary; + + /** + * 级别(比例)工资 + */ + private Long gradeSalary; + + /** + * 生活性补贴 + */ + private Long livingSubsidy; + + /** + * 工作性津贴 + */ + private Long workAllowance; + + /** + * 基础绩效奖 + */ + private Long basicPerformance; + + /** + * 警衔津贴 + */ + private Long policeRankAllowance; + + /** + * 执勤津贴 + */ + private Long dutyAllowance; + + /** + * 加班补贴 + */ + private Long overtimePay; + + /** + * 乡镇工作津贴 + */ + private Long townshipWorkAllowance; + + /** + * 扣个人所得税 + */ + private Long individualIncomeTax; + + /** + * 扣医疗保险金 + */ + private Long medicalInsuranceFund; + + /** + * 扣住房公积金 + */ + private Long housingFund; + + /** + * 扣基本养老金 + */ + private Long basicPension; + + /** + * 扣职业年金 + */ + private Long occupationalPension; + + /** + * 其他代扣 + */ + private Long otherDeduction; + + /** + * 扣款小计 + */ + private Long totalDeduction; + + /** + * 增发 + */ + private Long increasePay; + + /** + * 减发 + */ + private Long reducePay; + + /** + * 应发 + */ + private Long totalPay; + + /** + * 实发 + */ + private Long actualSalary; + + /** + * 备注 + */ + private String remark; + + /** + * 创建用户ID + */ + private Long createUserId; + + +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryImportVo.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryImportVo.java new file mode 100644 index 0000000..534a571 --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryImportVo.java @@ -0,0 +1,222 @@ +package com.ruans.biz.domain.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.ruans.common.excel.annotation.ExcelDictFormat; +import com.ruans.common.excel.convert.ExcelDictConvert; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 工资明细对象导入VO + * + * @author YIN + */ + +@Data +@NoArgsConstructor +// @Accessors(chain = true) // 导入不允许使用 会找不到set方法 +public class BizSalaryImportVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private Long id; + + /** + * 工资类型 + */ + @ExcelProperty(value = "工资类型") + private String salaryType; + + /** + * 用户ID + */ + private Long userId; + + /** + * 警号 + */ + private String policeNo; + + /** + * 人员姓名 + */ + @ExcelProperty(value = "人员姓名") + private String policeName; + + /** + * 身份证号 + */ + @ExcelProperty(value = "身份证号") + private String idcard; + + /** + * 银行卡号 + */ + @ExcelProperty(value = "银行卡号") + private String bankCard; + + /** + * 部门ID + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 工资月份 + */ + @ExcelProperty(value = "月份") + private String yearMonth; + + /** + * 年份 + */ + private Long salaryYear; + + /** + * 月份 + */ + private Long salaryMonth; + + /** + * 职务(技术等级)工资 + */ + @ExcelProperty(value = "职务(技术等级)工资") + private Long postSalary; + + /** + * 级别(比例)工资 + */ + @ExcelProperty(value = "级别(比例)工资") + private Long gradeSalary; + + /** + * 生活性补贴 + */ + @ExcelProperty(value = "生活性补贴") + private Long livingSubsidy; + + /** + * 工作性津贴 + */ + @ExcelProperty(value = "工作性津贴") + private Long workAllowance; + + /** + * 基础绩效奖 + */ + @ExcelProperty(value = "基础绩效奖") + private Long basicPerformance; + + /** + * 警衔津贴 + */ + @ExcelProperty(value = "警衔津贴") + private Long policeRankAllowance; + + /** + * 执勤津贴 + */ + @ExcelProperty(value = "执勤津贴") + private Long dutyAllowance; + + /** + * 加班补贴 + */ + @ExcelProperty(value = "加班补贴") + private Long overtimePay; + + /** + * 乡镇工作津贴 + */ + @ExcelProperty(value = "乡镇工作津贴") + private Long townshipWorkAllowance; + + /** + * 扣个人所得税 + */ + @ExcelProperty(value = "扣个人所得税") + private Long individualIncomeTax; + + /** + * 扣医疗保险金 + */ + @ExcelProperty(value = "扣医疗保险金") + private Long medicalInsuranceFund; + + /** + * 扣住房公积金 + */ + @ExcelProperty(value = "扣住房公积金") + private Long housingFund; + + /** + * 扣基本养老金 + */ + @ExcelProperty(value = "扣基本养老金") + private Long basicPension; + + /** + * 扣职业年金 + */ + @ExcelProperty(value = "扣职业年金") + private Long occupationalPension; + + /** + * 其他代扣 + */ + @ExcelProperty(value = "其他代扣") + private Long otherDeduction; + + /** + * 扣款小计 + */ + @ExcelProperty(value = "扣款小计") + private Long totalDeduction; + + /** + * 增发 + */ + @ExcelProperty(value = "增发") + private Long increasePay; + + /** + * 减发 + */ + @ExcelProperty(value = "减发") + private Long reducePay; + + /** + * 应发 + */ + @ExcelProperty(value = "应发") + private Long totalPay; + + /** + * 实发 + */ + @ExcelProperty(value = "实发") + private Long actualSalary; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + /** + * 创建用户ID + */ + private Long createUserId; + +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryVo.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryVo.java new file mode 100644 index 0000000..b06a6cc --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/domain/vo/BizSalaryVo.java @@ -0,0 +1,228 @@ +package com.ruans.biz.domain.vo; + +import com.ruans.biz.domain.BizSalary; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.ruans.common.excel.annotation.ExcelDictFormat; +import com.ruans.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + + +/** + * 工资明细视图对象 biz_salary + * + * @author YIN + * @date 2026-03-25 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = BizSalary.class) +public class BizSalaryVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private Long id; + + /** + * 工资类型 + */ + @ExcelProperty(value = "工资类型") + private String salaryType; + + /** + * 用户ID + */ + private Long userId; + + /** + * 警号 + */ + private String policeNo; + + /** + * 人员姓名 + */ + @ExcelProperty(value = "人员姓名") + private String policeName; + + /** + * 身份证号 + */ + @ExcelProperty(value = "身份证号") + private String idcard; + + /** + * 银行卡号 + */ + @ExcelProperty(value = "银行卡号") + private String bankCard; + + /** + * 部门ID + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 工资月份 + */ + @ExcelProperty(value = "月份") + private String yearMonth; + + /** + * 年份 + */ + private Long salaryYear; + + /** + * 月份 + */ + private Long salaryMonth; + + /** + * 职务(技术等级)工资 + */ + @ExcelProperty(value = "职务(技术等级)工资") + private Long postSalary; + + /** + * 级别(比例)工资 + */ + @ExcelProperty(value = "级别(比例)工资") + private Long gradeSalary; + + /** + * 生活性补贴 + */ + @ExcelProperty(value = "生活性补贴") + private Long livingSubsidy; + + /** + * 工作性津贴 + */ + @ExcelProperty(value = "工作性津贴") + private Long workAllowance; + + /** + * 基础绩效奖 + */ + @ExcelProperty(value = "基础绩效奖") + private Long basicPerformance; + + /** + * 警衔津贴 + */ + @ExcelProperty(value = "警衔津贴") + private Long policeRankAllowance; + + /** + * 执勤津贴 + */ + @ExcelProperty(value = "执勤津贴") + private Long dutyAllowance; + + /** + * 加班补贴 + */ + @ExcelProperty(value = "加班补贴") + private Long overtimePay; + + /** + * 乡镇工作津贴 + */ + @ExcelProperty(value = "乡镇工作津贴") + private Long townshipWorkAllowance; + + /** + * 扣个人所得税 + */ + @ExcelProperty(value = "扣个人所得税") + private Long individualIncomeTax; + + /** + * 扣医疗保险金 + */ + @ExcelProperty(value = "扣医疗保险金") + private Long medicalInsuranceFund; + + /** + * 扣住房公积金 + */ + @ExcelProperty(value = "扣住房公积金") + private Long housingFund; + + /** + * 扣基本养老金 + */ + @ExcelProperty(value = "扣基本养老金") + private Long basicPension; + + /** + * 扣职业年金 + */ + @ExcelProperty(value = "扣职业年金") + private Long occupationalPension; + + /** + * 其他代扣 + */ + @ExcelProperty(value = "其他代扣") + private Long otherDeduction; + + /** + * 扣款小计 + */ + @ExcelProperty(value = "扣款小计") + private Long totalDeduction; + + /** + * 增发 + */ + @ExcelProperty(value = "增发") + private Long increasePay; + + /** + * 减发 + */ + @ExcelProperty(value = "减发") + private Long reducePay; + + /** + * 应发 + */ + @ExcelProperty(value = "应发") + private Long totalPay; + + /** + * 实发 + */ + @ExcelProperty(value = "实发") + private Long actualSalary; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + /** + * 创建用户ID + */ + private Long createUserId; + + +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/mapper/BizSalaryMapper.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/mapper/BizSalaryMapper.java new file mode 100644 index 0000000..1ff5e02 --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/mapper/BizSalaryMapper.java @@ -0,0 +1,15 @@ +package com.ruans.biz.mapper; + +import com.ruans.biz.domain.BizSalary; +import com.ruans.biz.domain.vo.BizSalaryVo; +import com.ruans.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 工资明细Mapper接口 + * + * @author YIN + * @date 2026-03-25 + */ +public interface BizSalaryMapper extends BaseMapperPlus { + +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/IBizSalaryService.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/IBizSalaryService.java new file mode 100644 index 0000000..47ee8c1 --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/IBizSalaryService.java @@ -0,0 +1,77 @@ +package com.ruans.biz.service; + +import com.ruans.biz.domain.vo.BizSalaryVo; +import com.ruans.biz.domain.bo.BizSalaryBo; +import com.ruans.common.mybatis.core.page.TableDataInfo; +import com.ruans.common.mybatis.core.page.PageQuery; + +import java.util.Collection; +import java.util.List; + +/** + * 工资明细Service接口 + * + * @author YIN + * @date 2026-03-25 + */ +public interface IBizSalaryService { + + /** + * 查询工资明细 + * + * @param id 主键 + * @return 工资明细 + */ + BizSalaryVo queryById(Long id); + + /** + * 通过身份证号查询工资明细 + * + * @param idCard 身份证号 + * @param yearMonth 工资月份 + * @return 工资明细对象信息 + */ + BizSalaryVo selectSalaryByIdCardAndMouth(String idCard, String yearMonth); + + /** + * 分页查询工资明细列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 工资明细分页列表 + */ + TableDataInfo queryPageList(BizSalaryBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的工资明细列表 + * + * @param bo 查询条件 + * @return 工资明细列表 + */ + List queryList(BizSalaryBo bo); + + /** + * 新增工资明细 + * + * @param bo 工资明细 + * @return 是否新增成功 + */ + Boolean insertByBo(BizSalaryBo bo); + + /** + * 修改工资明细 + * + * @param bo 工资明细 + * @return 是否修改成功 + */ + Boolean updateByBo(BizSalaryBo bo); + + /** + * 校验并批量删除工资明细信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/impl/BizSalaryServiceImpl.java b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/impl/BizSalaryServiceImpl.java new file mode 100644 index 0000000..221e357 --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/biz/service/impl/BizSalaryServiceImpl.java @@ -0,0 +1,174 @@ +package com.ruans.biz.service.impl; + +import com.ruans.common.core.utils.MapstructUtils; +import com.ruans.common.core.utils.StringUtils; +import com.ruans.common.mybatis.core.page.TableDataInfo; +import com.ruans.common.mybatis.core.page.PageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruans.system.domain.SysUser; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import com.ruans.biz.domain.bo.BizSalaryBo; +import com.ruans.biz.domain.vo.BizSalaryVo; +import com.ruans.biz.domain.BizSalary; +import com.ruans.biz.mapper.BizSalaryMapper; +import com.ruans.biz.service.IBizSalaryService; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 工资明细Service业务层处理 + * + * @author YIN + * @date 2026-03-25 + */ +@RequiredArgsConstructor +@Service +public class BizSalaryServiceImpl implements IBizSalaryService { + + private final BizSalaryMapper baseMapper; + + /** + * 查询工资明细 + * + * @param id 主键 + * @return 工资明细 + */ + @Override + public BizSalaryVo queryById(Long id){ + return baseMapper.selectVoById(id); + } + + /** + * 通过身份证号查询工资明细 + * + * @param idcard 身份证号 + * @param yearMonth 身份证号 + * @return 工资明细对象信息 + */ + @Override + public BizSalaryVo selectSalaryByIdCardAndMouth(String idcard, String yearMonth){ + return baseMapper.selectVoOne(new LambdaQueryWrapper().eq(BizSalary::getIdcard, idcard).eq(BizSalary::getYearMonth, yearMonth)); + } + + /** + * 分页查询工资明细列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 工资明细分页列表 + */ + @Override + public TableDataInfo queryPageList(BizSalaryBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的工资明细列表 + * + * @param bo 查询条件 + * @return 工资明细列表 + */ + @Override + public List queryList(BizSalaryBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(BizSalaryBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(BizSalary::getId); + lqw.eq(StringUtils.isNotBlank(bo.getSalaryType()), BizSalary::getSalaryType, bo.getSalaryType()); + lqw.eq(bo.getUserId() != null, BizSalary::getUserId, bo.getUserId()); + lqw.eq(StringUtils.isNotBlank(bo.getPoliceNo()), BizSalary::getPoliceNo, bo.getPoliceNo()); + lqw.like(StringUtils.isNotBlank(bo.getPoliceName()), BizSalary::getPoliceName, bo.getPoliceName()); + lqw.eq(StringUtils.isNotBlank(bo.getIdcard()), BizSalary::getIdcard, bo.getIdcard()); + lqw.eq(StringUtils.isNotBlank(bo.getBankCard()), BizSalary::getBankCard, bo.getBankCard()); + lqw.eq(StringUtils.isNotBlank(bo.getDeptId()), BizSalary::getDeptId, bo.getDeptId()); + lqw.like(StringUtils.isNotBlank(bo.getDeptName()), BizSalary::getDeptName, bo.getDeptName()); + lqw.eq(StringUtils.isNotBlank(bo.getYearMonth()), BizSalary::getYearMonth, bo.getYearMonth()); + lqw.eq(bo.getSalaryYear() != null, BizSalary::getSalaryYear, bo.getSalaryYear()); + lqw.eq(bo.getSalaryMonth() != null, BizSalary::getSalaryMonth, bo.getSalaryMonth()); + lqw.eq(bo.getPostSalary() != null, BizSalary::getPostSalary, bo.getPostSalary()); + lqw.eq(bo.getGradeSalary() != null, BizSalary::getGradeSalary, bo.getGradeSalary()); + lqw.eq(bo.getLivingSubsidy() != null, BizSalary::getLivingSubsidy, bo.getLivingSubsidy()); + lqw.eq(bo.getWorkAllowance() != null, BizSalary::getWorkAllowance, bo.getWorkAllowance()); + lqw.eq(bo.getBasicPerformance() != null, BizSalary::getBasicPerformance, bo.getBasicPerformance()); + lqw.eq(bo.getPoliceRankAllowance() != null, BizSalary::getPoliceRankAllowance, bo.getPoliceRankAllowance()); + lqw.eq(bo.getDutyAllowance() != null, BizSalary::getDutyAllowance, bo.getDutyAllowance()); + lqw.eq(bo.getOvertimePay() != null, BizSalary::getOvertimePay, bo.getOvertimePay()); + lqw.eq(bo.getTownshipWorkAllowance() != null, BizSalary::getTownshipWorkAllowance, bo.getTownshipWorkAllowance()); + lqw.eq(bo.getIndividualIncomeTax() != null, BizSalary::getIndividualIncomeTax, bo.getIndividualIncomeTax()); + lqw.eq(bo.getMedicalInsuranceFund() != null, BizSalary::getMedicalInsuranceFund, bo.getMedicalInsuranceFund()); + lqw.eq(bo.getHousingFund() != null, BizSalary::getHousingFund, bo.getHousingFund()); + lqw.eq(bo.getBasicPension() != null, BizSalary::getBasicPension, bo.getBasicPension()); + lqw.eq(bo.getOccupationalPension() != null, BizSalary::getOccupationalPension, bo.getOccupationalPension()); + lqw.eq(bo.getOtherDeduction() != null, BizSalary::getOtherDeduction, bo.getOtherDeduction()); + lqw.eq(bo.getTotalDeduction() != null, BizSalary::getTotalDeduction, bo.getTotalDeduction()); + lqw.eq(bo.getIncreasePay() != null, BizSalary::getIncreasePay, bo.getIncreasePay()); + lqw.eq(bo.getReducePay() != null, BizSalary::getReducePay, bo.getReducePay()); + lqw.eq(bo.getTotalPay() != null, BizSalary::getTotalPay, bo.getTotalPay()); + lqw.eq(bo.getActualSalary() != null, BizSalary::getActualSalary, bo.getActualSalary()); + lqw.eq(bo.getCreateUserId() != null, BizSalary::getCreateUserId, bo.getCreateUserId()); + return lqw; + } + + /** + * 新增工资明细 + * + * @param bo 工资明细 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(BizSalaryBo bo) { + BizSalary add = MapstructUtils.convert(bo, BizSalary.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改工资明细 + * + * @param bo 工资明细 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(BizSalaryBo bo) { + BizSalary update = MapstructUtils.convert(bo, BizSalary.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(BizSalary entity){ + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除工资明细信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/system/listener/BizSalaryImportListener.java b/ruans-modules/ruans-system/src/main/java/com/ruans/system/listener/BizSalaryImportListener.java new file mode 100644 index 0000000..c3494af --- /dev/null +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/system/listener/BizSalaryImportListener.java @@ -0,0 +1,136 @@ +package com.ruans.system.listener; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.crypto.digest.BCrypt; +import cn.hutool.http.HtmlUtil; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.ruans.biz.domain.bo.BizSalaryBo; +import com.ruans.biz.domain.vo.BizSalaryVo; +import com.ruans.biz.service.IBizSalaryService; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import com.ruans.common.core.exception.ServiceException; +import com.ruans.common.core.utils.SpringUtils; +import com.ruans.common.core.utils.StreamUtils; +import com.ruans.common.core.utils.ValidatorUtils; +import com.ruans.common.excel.core.ExcelListener; +import com.ruans.common.excel.core.ExcelResult; +import com.ruans.common.satoken.utils.LoginHelper; +import com.ruans.system.domain.bo.SysUserBo; +import com.ruans.biz.domain.vo.BizSalaryImportVo; +import com.ruans.system.domain.vo.SysUserVo; +import com.ruans.system.service.ISysConfigService; +import com.ruans.system.service.ISysUserService; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * 工资明细自定义导入 + * + * @author YIN + */ +@Slf4j +public class BizSalaryImportListener extends AnalysisEventListener implements ExcelListener { + + private final ISysUserService userService; + private final IBizSalaryService salaryService; + + private final Boolean isUpdateSupport; + + private final Long operUserId; + + private int successNum = 0; + private int failureNum = 0; + private final StringBuilder successMsg = new StringBuilder(); + private final StringBuilder failureMsg = new StringBuilder(); + + public BizSalaryImportListener(Boolean isUpdateSupport) { + + this.userService = SpringUtils.getBean(ISysUserService.class); + this.salaryService = SpringUtils.getBean(IBizSalaryService.class); + + this.isUpdateSupport = isUpdateSupport; + this.operUserId = LoginHelper.getUserId(); + } + + @Override + public void invoke(BizSalaryImportVo importVo, AnalysisContext context) { + BizSalaryVo salaryVo = this.salaryService.selectSalaryByIdCardAndMouth(importVo.getIdcard(), importVo.getYearMonth()); + try { + SysUserVo dbUser = this.userService.selectUserByIdCard(importVo.getIdcard()); + importVo.setUserId(dbUser.getUserId()); + importVo.setPoliceNo(dbUser.getUserName()); + importVo.setDeptId(dbUser.getWorkDeptId()); + importVo.setDeptName(dbUser.getWorkDeptName()); + + // 验证是否存在这个用户 + if (ObjectUtil.isNull(salaryVo)) { + + BizSalaryBo salary = BeanUtil.toBean(importVo, BizSalaryBo.class); + ValidatorUtils.validate(salary); + + salary.setCreateUserId(operUserId); + salaryService.insertByBo(salary); + successNum++; + successMsg.append("
").append(successNum).append("、工资明细 ").append(salary.getPoliceName()).append(" 导入成功"); + } else if (isUpdateSupport) { + Long id = salaryVo.getId(); + BizSalaryBo salary = BeanUtil.toBean(importVo, BizSalaryBo.class); + salary.setUserId(id); + ValidatorUtils.validate(salary); + + salary.setUpdateBy(operUserId); + salaryService.updateByBo(salary); + successNum++; + successMsg.append("
").append(successNum).append("、工资明细 ").append(salary.getPoliceName()).append(" 更新成功"); + } else { + failureNum++; + failureMsg.append("
").append(failureNum).append("、工资明细 ").append(salaryVo.getPoliceName()).append(" 已存在"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、工资明细 " + HtmlUtil.cleanHtmlTag(salaryVo.getPoliceName()) + " 导入失败:"; + String message = e.getMessage(); + if (e instanceof ConstraintViolationException cvException) { + message = StreamUtils.join(cvException.getConstraintViolations(), ConstraintViolation::getMessage, ", "); + } + failureMsg.append(msg).append(message); + log.error(msg, e); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } + + @Override + public ExcelResult getExcelResult() { + return new ExcelResult<>() { + + @Override + public String getAnalysis() { + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + + @Override + public List getList() { + return null; + } + + @Override + public List getErrorList() { + return null; + } + }; + } +} diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/ISysUserService.java b/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/ISysUserService.java index fe35ab7..9bcc5ef 100644 --- a/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/ISysUserService.java +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/ISysUserService.java @@ -50,6 +50,14 @@ public interface ISysUserService { */ SysUserVo selectUserByUserName(String userName); + /** + * 通过身份证号查询用户 + * + * @param idCard 身份证号 + * @return 用户对象信息 + */ + SysUserVo selectUserByIdCard(String idCard); + /** * 通过手机号查询用户 * diff --git a/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/impl/SysUserServiceImpl.java b/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/impl/SysUserServiceImpl.java index 9f0619c..1821bb0 100644 --- a/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/impl/SysUserServiceImpl.java +++ b/ruans-modules/ruans-system/src/main/java/com/ruans/system/service/impl/SysUserServiceImpl.java @@ -145,6 +145,17 @@ public class SysUserServiceImpl implements ISysUserService, UserService { return baseMapper.selectVoOne(new LambdaQueryWrapper().eq(SysUser::getUserName, userName)); } + /** + * 通过身份证号查询用户 + * + * @param idCard 身份证号 + * @return 用户对象信息 + */ + @Override + public SysUserVo selectUserByIdCard(String idCard) { + return baseMapper.selectVoOne(new LambdaQueryWrapper().eq(SysUser::getIdCard, idCard)); + } + /** * 通过手机号查询用户 * diff --git a/ruans-modules/ruans-system/src/main/resources/mapper/biz/BizSalaryMapper.xml b/ruans-modules/ruans-system/src/main/resources/mapper/biz/BizSalaryMapper.xml new file mode 100644 index 0000000..49ca180 --- /dev/null +++ b/ruans-modules/ruans-system/src/main/resources/mapper/biz/BizSalaryMapper.xml @@ -0,0 +1,7 @@ + + + + +