工资明细

master
YIN 2026-03-25 17:42:26 +08:00
parent f9b4efbf43
commit 728775b21a
15 changed files with 1407 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@ gen:
# 作者
author: Lion Li
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: org.dromara.system
packageName: com.ruans.system
# 自动去除表前缀默认是false
autoRemovePre: false
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)

View File

@ -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<BizSalaryVo> 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<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
ExcelResult<BizSalaryImportVo> 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<BizSalaryVo> list = bizSalaryService.queryList(bo);
ExcelUtil.exportExcel(list, "工资明细", BizSalaryVo.class, response);
}
/**
*
*
* @param id
*/
@SaCheckPermission("biz:salary:query")
@GetMapping("/{id}")
public R<BizSalaryVo> 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<Void> 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<Void> 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<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(bizSalaryService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<BizSalary, BizSalaryVo> {
}

View File

@ -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<BizSalaryVo> queryPageList(BizSalaryBo bo, PageQuery pageQuery);
/**
*
*
* @param bo
* @return
*/
List<BizSalaryVo> 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<Long> ids, Boolean isValid);
}

View File

@ -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<BizSalary>().eq(BizSalary::getIdcard, idcard).eq(BizSalary::getYearMonth, yearMonth));
}
/**
*
*
* @param bo
* @param pageQuery
* @return
*/
@Override
public TableDataInfo<BizSalaryVo> queryPageList(BizSalaryBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BizSalary> lqw = buildQueryWrapper(bo);
Page<BizSalaryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
*
*
* @param bo
* @return
*/
@Override
public List<BizSalaryVo> queryList(BizSalaryBo bo) {
LambdaQueryWrapper<BizSalary> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<BizSalary> buildQueryWrapper(BizSalaryBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<BizSalary> 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<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -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<BizSalaryImportVo> implements ExcelListener<BizSalaryImportVo> {
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("<br/>").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("<br/>").append(successNum).append("、工资明细 ").append(salary.getPoliceName()).append(" 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、工资明细 ").append(salaryVo.getPoliceName()).append(" 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + 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<BizSalaryImportVo> 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<BizSalaryImportVo> getList() {
return null;
}
@Override
public List<String> getErrorList() {
return null;
}
};
}
}

View File

@ -50,6 +50,14 @@ public interface ISysUserService {
*/
SysUserVo selectUserByUserName(String userName);
/**
*
*
* @param idCard
* @return
*/
SysUserVo selectUserByIdCard(String idCard);
/**
*
*

View File

@ -145,6 +145,17 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
}
/**
*
*
* @param idCard
* @return
*/
@Override
public SysUserVo selectUserByIdCard(String idCard) {
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getIdCard, idCard));
}
/**
*
*

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruans.biz.mapper.BizSalaryMapper">
</mapper>