huminmin
6 天以前 8c5464464036193ddac1de2c5155c94141545c7c
src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
@@ -2,35 +2,33 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.UserAccountDto;
import com.ruoyi.production.dto.UserProductionAccountingDto;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.production.bean.dto.UserAccountDto;
import com.ruoyi.production.bean.dto.UserProductionAccountingDto;
import com.ruoyi.production.service.SalesLedgerProductionAccountingService;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.domain.SysUserDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.project.system.mapper.SysUserDeptMapper;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.staff.controller.TaxCalculator;
import com.ruoyi.staff.dto.StaffOnJobDto;
import com.ruoyi.staff.mapper.SchemeApplicableStaffMapper;
import com.ruoyi.staff.mapper.SchemeInsuranceDetailMapper;
import com.ruoyi.staff.mapper.StaffOnJobMapper;
import com.ruoyi.staff.pojo.SchemeApplicableStaff;
import com.ruoyi.staff.mapper.SchemeApplicableStaffMapper;
import com.ruoyi.staff.pojo.SchemeInsuranceDetail;
import com.ruoyi.staff.pojo.StaffOnJob;
import com.ruoyi.staff.service.IStaffOnJobService;
import com.ruoyi.staff.service.SchemeApplicableStaffService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -42,32 +40,19 @@
 * @since 2026-03-05 11:50:17
 */
@Service
@RequiredArgsConstructor
public class SchemeApplicableStaffServiceImpl extends ServiceImpl<SchemeApplicableStaffMapper, SchemeApplicableStaff> implements SchemeApplicableStaffService {
    @Autowired
    private SchemeApplicableStaffMapper schemeApplicableStaffMapper;
    @Autowired
    private SchemeInsuranceDetailMapper schemeInsuranceDetailMapper;
    @Autowired
    private SysUserDeptMapper sysUserDeptMapper;
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private SysDeptMapper sysDeptMapper;
    @Autowired
    private StaffOnJobMapper staffOnJobMapper;
    @Autowired
    private SalesLedgerProductionAccountingService salesLedgerProductionAccountingService;
    private final SchemeApplicableStaffMapper schemeApplicableStaffMapper;
    private final SchemeInsuranceDetailMapper schemeInsuranceDetailMapper;
    private final SysUserMapper sysUserMapper;
    private final SysDeptMapper sysDeptMapper;
    private final StaffOnJobMapper staffOnJobMapper;
    private final SalesLedgerProductionAccountingService salesLedgerProductionAccountingService;
    @Override
    public AjaxResult listPage(Page page, SchemeApplicableStaff schemeApplicableStaff) {
    public R<?> listPage(Page page, SchemeApplicableStaff schemeApplicableStaff) {
        LambdaQueryWrapper<SchemeApplicableStaff> schemeApplicableStaffLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(schemeApplicableStaff != null){
            if(StringUtils.isNotEmpty(schemeApplicableStaff.getTitle())){
@@ -77,7 +62,7 @@
        Page<SchemeApplicableStaff> page1 = schemeApplicableStaffMapper.selectPage(page, schemeApplicableStaffLambdaQueryWrapper);
        List<Long> collect = page1.getRecords().stream().map(SchemeApplicableStaff::getId).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(collect)){
            return AjaxResult.success(page1);
            return R.ok(page1);
        }
        List<SchemeInsuranceDetail> schemeInsuranceDetails = schemeInsuranceDetailMapper
                .selectList(new LambdaQueryWrapper<SchemeInsuranceDetail>()
@@ -97,7 +82,7 @@
                item.setDeptNames(sysDepts.stream().map(SysDept::getDeptName).collect(Collectors.joining(",")));
            }
        });
        return AjaxResult.success(page1);
        return R.ok(page1);
    }
    public void setSchemeApplicableStaffUserInfo(SchemeApplicableStaff schemeApplicableStaff) {
@@ -118,12 +103,12 @@
    }
    @Override
    public AjaxResult add(SchemeApplicableStaff schemeApplicableStaff) {
    public R<?> add(SchemeApplicableStaff schemeApplicableStaff) {
        if(schemeApplicableStaff == null){
            return AjaxResult.error("参数错误");
            return R.fail("参数错误");
        }
        if(CollectionUtils.isEmpty(schemeApplicableStaff.getSchemeInsuranceDetailList())){
            return AjaxResult.error("请选择方案明细");
            return R.fail("请选择方案明细");
        }
        setSchemeApplicableStaffUserInfo(schemeApplicableStaff); //根据部门设置用户信息
        int insert = schemeApplicableStaffMapper.insert(schemeApplicableStaff);
@@ -131,13 +116,13 @@
            item.setSchemeId(schemeApplicableStaff.getId());
            schemeInsuranceDetailMapper.insert(item);
        });
        return AjaxResult.success(insert);
        return R.ok(insert);
    }
    @Override
    public AjaxResult updateSchemeApplicableStaff(SchemeApplicableStaff schemeApplicableStaff) {
    public R<?> updateSchemeApplicableStaff(SchemeApplicableStaff schemeApplicableStaff) {
        if(schemeApplicableStaff == null){
            return AjaxResult.error("参数错误");
            return R.fail("参数错误");
        }
        setSchemeApplicableStaffUserInfo(schemeApplicableStaff); //根据部门设置用户信息
        int update = schemeApplicableStaffMapper.updateById(schemeApplicableStaff);
@@ -148,18 +133,18 @@
            item.setSchemeId(schemeApplicableStaff.getId());
            schemeInsuranceDetailMapper.insert(item);
        });
        return AjaxResult.success(update);
        return R.ok(update);
    }
    @Override
    public AjaxResult delete(List<Long> ids) {
    public R<?> delete(List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return AjaxResult.error("参数错误");
            return R.fail("参数错误");
        }
        int delete = schemeApplicableStaffMapper.deleteBatchIds(ids);
        schemeInsuranceDetailMapper.delete(new LambdaQueryWrapper<SchemeInsuranceDetail>()
                .in(SchemeInsuranceDetail::getSchemeId, ids));
        return AjaxResult.success(delete);
        return R.ok(delete);
    }
    /**