From 786b6a88d5f7533585a02483697ca46a51561549 Mon Sep 17 00:00:00 2001 From: hshansha Date: Wed, 11 Jun 2025 16:42:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E3=80=81=E6=B3=A8=E5=86=8C=E6=97=B6=E6=9D=A1=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=91=98=E5=B7=A5=E6=9F=A5=E8=AF=A2=E5=B7=A5?= =?UTF-8?q?=E8=B5=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysRegisterController.java | 2 +- .../controller/system/SysUserController.java | 4 +- .../ruoyi/pay/controller/WxController.java | 81 +++++++++++++++++++ .../service/impl/SysUserServiceImpl.java | 8 +- 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 ruoyi-pay/src/main/java/com/ruoyi/pay/controller/WxController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java index fc7a025..88b3336 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -84,7 +84,7 @@ public class SysRegisterController extends BaseController { } if(iPayTenantService.insertByBo(bo)){ //公司注册成功后自动添加角色:管理员 todo - Long[] adids={1L, 1921833283434213378L, 1921827581902888962L, 1921827581902888963L, 1921827581902888964L, 1921827581902888965L, 1921827581902888966L, 1921827581902888967L, 1921833488053334018L, 1921827579365335041L, 1921827579365335042L, 1921827579365335043L, 1921827579365335044L, 1921827579365335045L, 1921827579365335046L, 1921827582745944066L, 1921827582745944067L, 1921827582745944068L, 1921827582745944069L, 1921827582745944070L, 1921827582745944071L, 1921827581055639553L, 1921827581055639554L, 1921827581055639555L, 1921827581055639556L, 1921827581055639557L, 1921827581055639558L, 1921827581252771841L, 1921827581252771842L, 1921827581252771843L, 1921827581252771844L, 1921827581252771845L, 1921827581252771846L, 1921834138757656577L, 1921827582162935809L, 1921827582162935810L, 1921827582162935811L, 1921827582162935812L, 1921827582162935813L, 1921827582162935814L, 1921827582490091522L, 1921827582490091523L, 1921827582490091524L, 1921827582490091525L, 1921827582490091526L, 1921827582490091527L, 1921827583140208641L, 1921827583140208642L, 1921827583140208643L, 1921827583140208644L, 1921827583140208645L, 1921827583140208646L, 1921827581449904130L, 1921827581449904131L, 1921827581449904132L, 1921827581449904133L, 1921827581449904134L, 1921827581449904135L, 1921827583601582082L, 1921827583601582083L, 1921827583601582084L, 1921827583601582085L, 1921827583601582086L, 1921827583601582087L, 1921835117498494977L, 1921827582880161794L, 1921827582880161795L, 1921827582880161796L, 1921827582880161797L, 1921827582880161798L, 1921827582880161799L, 100L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 101L, 1010L, 1011L, 1012L, 1013L, 1014L}; + Long[] adids={1L, 1921827581902888962L, 1921827581902888963L, 1921827581902888964L, 1921827581902888965L, 1921827581902888966L, 1921827581902888967L, 1925831567442079745L, 103L, 1030L, 1031L, 1032L, 1033L, 1921833488053334018L, 1921827579365335041L, 1921827579365335042L, 1921827579365335043L, 1921827579365335044L, 1921827579365335045L, 1921827579365335046L, 1923557328978636802L, 1921827582745944066L, 1921827582745944067L, 1921827582745944068L, 1921827582745944069L, 1921827582745944070L, 1921827582745944071L, 1924730554400305154L, 1921827581055639553L, 1921827581055639554L, 1921827581055639555L, 1921827581055639556L, 1921827581055639557L, 1921827581055639558L, 1921827581252771841L, 1921827581252771842L, 1921827581252771843L, 1921827581252771844L, 1921827581252771845L, 1921827581252771846L, 1928011063268118530L, 1921834138757656577L, 1921827582162935809L, 1921827582162935810L, 1921827582162935811L, 1921827582162935812L, 1921827582162935813L, 1921827582162935814L, 1921827582490091522L, 1921827582490091523L, 1921827582490091524L, 1921827582490091525L, 1921827582490091526L, 1921827582490091527L, 1921827583140208641L, 1921827583140208642L, 1921827583140208643L, 1921827583140208644L, 1921827583140208645L, 1921827583140208646L, 1928258489392517122L, 1921827583601582082L, 1921827583601582083L, 1921827583601582084L, 1921827583601582085L, 1921827583601582086L, 1921827583601582087L, 1921827581449904130L, 1921827581449904131L, 1921827581449904132L, 1921827581449904133L, 1921827581449904134L, 1921827581449904135L, 1921835117498494977L, 1921827582880161794L, 1921827582880161795L, 1921827582880161796L, 1921827582880161797L, 1921827582880161798L, 1921827582880161799L, 1930900100035280898L, 100L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 101L, 1010L, 1011L, 1012L, 1013L, 1014L}; Long[] ygids={1921835117498494977L, 1921827582880161794L, 1921827582880161795L}; SysRole role1 = new SysRole(); role1.setRoleKey("companyAdmin"); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 4e56a02..e431145 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -152,8 +152,8 @@ public class SysUserController extends BaseController { return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); - } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkNickNameUnique(user)) { - return R.fail("新增用户'" + user.getUserName() + "'失败,用户已存在"); + } else if (StringUtils.isNotEmpty(user.getNickName()) && !userService.checkNickNameUnique(user)) { + return R.fail("新增用户'" + user.getUserName() + "'失败,用户昵称已存在"); } user.setPassword(BCrypt.hashpw(user.getPassword())); return toAjax(userService.insertUser(user)); diff --git a/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/WxController.java b/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/WxController.java new file mode 100644 index 0000000..558fc19 --- /dev/null +++ b/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/WxController.java @@ -0,0 +1,81 @@ +package com.ruoyi.pay.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.PageQuery; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.validate.AddGroup; +import com.ruoyi.common.core.validate.EditGroup; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.pay.domain.PayDayWorkHoursQuery; +import com.ruoyi.pay.domain.PaySalaryReport; +import com.ruoyi.pay.domain.bo.PayAttendanceBo; +import com.ruoyi.pay.domain.bo.PaySalaryReportBo; +import com.ruoyi.pay.domain.vo.PayAttendanceVo; +import com.ruoyi.pay.domain.vo.PaySalaryReportVo; +import com.ruoyi.pay.service.IPayAttendanceService; +import com.ruoyi.pay.service.IPayDayWorkHoursService; +import com.ruoyi.pay.service.IPaySalaryReportService; +import com.ruoyi.pay.util.AttendanceExcelUtil; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 微信移动端接口 + * + * @author ruoyi + * @date 2025-05-12 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/pay/wx/emp") +public class WxController extends BaseController { + + private final IPaySalaryReportService paySalaryReportService; + private final IPayDayWorkHoursService payDayWorkHoursService; + + /** + * 员工查询个人工资得接口 + */ + @GetMapping("/salary") + public TableDataInfo getSalaryReportForEmployee(PaySalaryReportBo bo) { + List list = paySalaryReportService.queryList(bo); + if(list!=null&&list.size()>0){ + if(list.get(0).getEmpQuery()==0){//如果状态为不可查询,返回null数据 + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("当前工资状态:不可查询"); + // rspData.setRows(new ArrayList()); + rspData.setTotal(0); + return rspData; + } + } + return TableDataInfo.build(list); + } + + /** + * 员工查询个人日工工时 + */ + @GetMapping("/dayWork") + public TableDataInfo getDayWorkForEmployee(PayDayWorkHoursQuery payDayWorkHoursQuery) { + List list =payDayWorkHoursService.selectPayDayWorkHoursList2(payDayWorkHoursQuery); + return TableDataInfo.build(list); + } + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index a38a70a..f2b6995 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -204,7 +204,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public boolean checkUserNameUnique(SysUser user) { boolean exist = baseMapper.exists(new LambdaQueryWrapper() .eq(SysUser::getUserName, user.getUserName()) - .eq(SysUser::getTenantId, user.getTenantId()) + // .eq(SysUser::getTenantId, user.getTenantId()) .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); return !exist; } @@ -219,7 +219,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public boolean checkNickNameUnique(SysUser user) { boolean exist = baseMapper.exists(new LambdaQueryWrapper() .eq(SysUser::getNickName, user.getNickName()) - .eq(SysUser::getTenantId, user.getTenantId()) + //.eq(SysUser::getTenantId, user.getTenantId()) .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); return !exist; } @@ -233,7 +233,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public boolean checkPhoneUnique(SysUser user) { boolean exist = baseMapper.exists(new LambdaQueryWrapper() .eq(SysUser::getPhonenumber, user.getPhonenumber()) - .eq(SysUser::getTenantId, user.getTenantId()) + // .eq(SysUser::getTenantId, user.getTenantId()) .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); return !exist; } @@ -247,7 +247,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { public boolean checkEmailUnique(SysUser user) { boolean exist = baseMapper.exists(new LambdaQueryWrapper() .eq(SysUser::getEmail, user.getEmail()) - .eq(SysUser::getTenantId, user.getTenantId()) + //.eq(SysUser::getTenantId, user.getTenantId()) .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); return !exist; } From e36a7ff9a4e3266321b6aacba44e65724829a57b Mon Sep 17 00:00:00 2001 From: hshansha Date: Wed, 11 Jun 2025 16:57:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/web/controller/system/SysRegisterController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java index 88b3336..b3bbf7d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -85,7 +85,7 @@ public class SysRegisterController extends BaseController { if(iPayTenantService.insertByBo(bo)){ //公司注册成功后自动添加角色:管理员 todo Long[] adids={1L, 1921827581902888962L, 1921827581902888963L, 1921827581902888964L, 1921827581902888965L, 1921827581902888966L, 1921827581902888967L, 1925831567442079745L, 103L, 1030L, 1031L, 1032L, 1033L, 1921833488053334018L, 1921827579365335041L, 1921827579365335042L, 1921827579365335043L, 1921827579365335044L, 1921827579365335045L, 1921827579365335046L, 1923557328978636802L, 1921827582745944066L, 1921827582745944067L, 1921827582745944068L, 1921827582745944069L, 1921827582745944070L, 1921827582745944071L, 1924730554400305154L, 1921827581055639553L, 1921827581055639554L, 1921827581055639555L, 1921827581055639556L, 1921827581055639557L, 1921827581055639558L, 1921827581252771841L, 1921827581252771842L, 1921827581252771843L, 1921827581252771844L, 1921827581252771845L, 1921827581252771846L, 1928011063268118530L, 1921834138757656577L, 1921827582162935809L, 1921827582162935810L, 1921827582162935811L, 1921827582162935812L, 1921827582162935813L, 1921827582162935814L, 1921827582490091522L, 1921827582490091523L, 1921827582490091524L, 1921827582490091525L, 1921827582490091526L, 1921827582490091527L, 1921827583140208641L, 1921827583140208642L, 1921827583140208643L, 1921827583140208644L, 1921827583140208645L, 1921827583140208646L, 1928258489392517122L, 1921827583601582082L, 1921827583601582083L, 1921827583601582084L, 1921827583601582085L, 1921827583601582086L, 1921827583601582087L, 1921827581449904130L, 1921827581449904131L, 1921827581449904132L, 1921827581449904133L, 1921827581449904134L, 1921827581449904135L, 1921835117498494977L, 1921827582880161794L, 1921827582880161795L, 1921827582880161796L, 1921827582880161797L, 1921827582880161798L, 1921827582880161799L, 1930900100035280898L, 100L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 101L, 1010L, 1011L, 1012L, 1013L, 1014L}; - Long[] ygids={1921835117498494977L, 1921827582880161794L, 1921827582880161795L}; + Long[] ygids={1921827582880161794L, 1921827582880161795L}; SysRole role1 = new SysRole(); role1.setRoleKey("companyAdmin"); role1.setRoleName("公司管理员"); From 1f6a10abc9f8bca65a3b7985bf6b511c506f70fc Mon Sep 17 00:00:00 2001 From: hshansha Date: Thu, 12 Jun 2025 11:53:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E6=97=B6=E6=B7=BB=E5=8A=A0=E9=99=90=E5=88=B6=E3=80=81=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysUserController.java | 35 +++++++++++-------- .../pay/controller/PayTenantController.java | 22 ++++++++++++ 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index e431145..9209a74 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -21,6 +21,10 @@ import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.utils.StreamUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.pay.domain.bo.PaySubInfoBo; +import com.ruoyi.pay.domain.vo.PaySubInfoVo; +import com.ruoyi.pay.service.IPaySubInfoService; +import com.ruoyi.pay.service.IPayTenantService; import com.ruoyi.system.domain.vo.SysUserExportVo; import com.ruoyi.system.domain.vo.SysUserImportVo; import com.ruoyi.system.listener.SysUserImportListener; @@ -30,15 +34,15 @@ import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import javax.validation.constraints.NotEmpty; +import java.util.*; +import java.util.stream.Collectors; /** * 用户管理 @@ -55,7 +59,8 @@ public class SysUserController extends BaseController { private final ISysRoleService roleService; private final ISysPostService postService; private final ISysDeptService deptService; - + private final IPaySubInfoService subInfoService; + private final IPayTenantService iPayTenantService; /** * 获取用户列表 @@ -259,14 +264,14 @@ public class SysUserController extends BaseController { } /** - * 删除公司信息 + * 删除租户信息 * * @param ids 主键串 */ -/* @SaCheckPermission("aftersale:company:remove") - @Log(title = "公司信息", businessType = BusinessType.DELETE) + @SaCheckPermission("pay:tenant:remove") + @Log(title = "租户信息", businessType = BusinessType.DELETE) @Transactional - @DeleteMapping("/company/{ids}") + @DeleteMapping("/tenant/{ids}") public R delete(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { for(Long id:ids){ @@ -288,14 +293,14 @@ public class SysUserController extends BaseController { roleService.deleteRoleByIds(rids.toArray(rids.toArray(new Long[rids.size()]))); } //删除公司订阅信息 - AsSubscriptionInfoBo subInfo=new AsSubscriptionInfoBo(); + PaySubInfoBo subInfo=new PaySubInfoBo(); subInfo.setTenantId(id); - List infoVos = iAsSubscriptionInfoService.queryList(subInfo); - List sids = infoVos.stream().map(AsSubscriptionInfoVo::getId).collect(Collectors.toList()); + List infoVos = subInfoService.queryList(subInfo); + List sids = infoVos.stream().map(PaySubInfoVo::getId).collect(Collectors.toList()); if(sids!=null&&sids.size()>0){ - iAsSubscriptionInfoService.deleteWithValidByIds(sids,true); + subInfoService.deleteWithValidByIds(sids,true); } } - return toAjax(iAsCompanyService.deleteWithValidByIds(Arrays.asList(ids), true)); - }*/ + return toAjax(iPayTenantService.deleteWithValidByIds(Arrays.asList(ids), true)); + } } diff --git a/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/PayTenantController.java b/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/PayTenantController.java index e8f80ab..901fc6f 100644 --- a/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/PayTenantController.java +++ b/ruoyi-pay/src/main/java/com/ruoyi/pay/controller/PayTenantController.java @@ -4,10 +4,14 @@ import java.util.List; import java.util.Arrays; import java.util.concurrent.TimeUnit; +import com.ruoyi.pay.domain.bo.PaySubInfoBo; +import com.ruoyi.pay.domain.vo.PaySubInfoVo; +import com.ruoyi.pay.service.IPaySubInfoService; import lombok.RequiredArgsConstructor; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import com.ruoyi.common.annotation.RepeatSubmit; @@ -38,6 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo; public class PayTenantController extends BaseController { private final IPayTenantService iPayTenantService; + private final IPaySubInfoService subInfoService; /** * 查询租户列表 @@ -101,8 +106,25 @@ public class PayTenantController extends BaseController { @SaCheckPermission("pay:tenant:edit") @Log(title = "租户", businessType = BusinessType.UPDATE) @RepeatSubmit() + @Transactional @PutMapping() public R edit(@Validated(EditGroup.class) @RequestBody PayTenantBo bo) { + //修改公司名要确保唯一性 + PayTenantBo queryBo = new PayTenantBo(); + queryBo.setName(bo.getName()); + List asCompany= iPayTenantService.queryList(queryBo); + if(asCompany!=null&&asCompany.size()>0&&!asCompany.get(0).getId().equals(bo.getId())){ + return new R().fail("修改失败,已有该公司名!"); + } + //公司修改名称 同时修改订阅计划中的公司名称 + PaySubInfoBo subInfo = new PaySubInfoBo(); + subInfo.setTenantId(bo.getId()); + List asSubscriptionInfoVos = subInfoService.queryList(subInfo); + if(asSubscriptionInfoVos!=null&&asSubscriptionInfoVos.size()>0){ + subInfo.setId(asSubscriptionInfoVos.get(0).getId()); + subInfo.setCompanyName(bo.getName()); + subInfoService.updateByBo(subInfo); + } return toAjax(iPayTenantService.updateByBo(bo)); } From a628585597cd04d61383b4501f28ac89f1302bba Mon Sep 17 00:00:00 2001 From: hshansha Date: Thu, 12 Jun 2025 15:47:10 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BD=BB=E5=BA=95=E6=B8=85=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysCompanyDataCleanController.java | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCompanyDataCleanController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCompanyDataCleanController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCompanyDataCleanController.java new file mode 100644 index 0000000..bca1232 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCompanyDataCleanController.java @@ -0,0 +1,195 @@ +package com.ruoyi.web.controller.system; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.service.DictService; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.pay.domain.PayAttendance; +import com.ruoyi.pay.domain.PayButie; +import com.ruoyi.pay.domain.PayEmployeeInfo; +import com.ruoyi.pay.domain.bo.*; +import com.ruoyi.pay.domain.vo.*; +import com.ruoyi.pay.mapper.*; +import com.ruoyi.pay.service.IPayEmployeeInfoService; +import com.ruoyi.pay.service.impl.*; +import com.ruoyi.system.service.ISysDeptService; +import com.ruoyi.system.service.impl.SysRoleServiceImpl; +import com.ruoyi.system.service.impl.SysUserServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 租户数据清理——彻底清理 + */ + +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/system/clean") +public class SysCompanyDataCleanController extends BaseController { + private final PaySalaryReportMapper salaryReportMapper; + private final PaySalaryReportServiceImpl salaryReportService; + private final PayEmployeeInfoServiceImpl payEmployeeInfoService; + private final PayButieEmplyeeServiceImpl payButieEmplyeeService; + private final PayButieServiceImpl butieService; + private final PayRequireAttendanceReportServiceImpl payRequireAttendanceReportService; + private final PayDayWorkHoursServiceImpl payDayWorkHoursService; + private final PayWorkOrderBaohuoServiceImpl payWorkOrderBaohuoService; + private final PayProductsServiceImpl payProductsService; + private final PayMaterialServiceImpl payMaterialService; + private final PayTenantServiceImpl payTenantService; + private final SysUserServiceImpl userService; + private final SysRoleServiceImpl roleService; + private final PayAttendanceServiceImpl payAttendanceService; + private final ISysDeptService deptService; + private final PaySubInfoServiceImpl subInfoService; + /** + * 数据清理 + * @param ids + * @return + * @throws Exception + */ + @SaCheckPermission("pay:company:clean") + @Log(title = "公司数据清理", businessType = BusinessType.DELETE) + @Transactional + @DeleteMapping("/tenant/{ids}") + public R delete(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) throws Exception { + for(Long id:ids){ + //删除公司下面的数据信息 + //工资总表 + PaySalaryReportBo salaryReportBo = new PaySalaryReportBo(); + salaryReportBo.setTenantId(id); + List asWorkOrderVos = salaryReportService.queryList(salaryReportBo); + List salaryids = asWorkOrderVos.stream().map(PaySalaryReportVo::getId).collect(Collectors.toList()); + if(salaryids!=null&&salaryids.size()>0){ + salaryReportService.deleteWithValidByIds(salaryids,true); + } + //日工工时 + PayDayWorkHoursBo riBo = new PayDayWorkHoursBo(); + riBo.setTenantId(id); + List riVos = payDayWorkHoursService.queryList(riBo); + List riids = riVos.stream().map(PayDayWorkHoursVo::getId).collect(Collectors.toList()); + if(riids!=null&&riids.size()>0) { + payDayWorkHoursService.deleteWithValidByIds(riids, true); + } + //包活工单 + PayWorkOrderBaohuoBo wBo = new PayWorkOrderBaohuoBo(); + wBo.setTenantId(id); + List rlVos = payWorkOrderBaohuoService.queryList(wBo); + List wids = rlVos.stream().map(PayWorkOrderBaohuoVo::getId).collect(Collectors.toList()); + if(wids!=null&&wids.size()>0) { + payWorkOrderBaohuoService.deleteWithValidByIds(wids,true); + } + //产品 + PayProductsBo pBo = new PayProductsBo(); + pBo.setTenantId(id); + List xjVos = payProductsService.queryList(pBo); + List xjids = xjVos.stream().map(PayProductsVo::getId).collect(Collectors.toList()); + if(xjids!=null&&xjids.size()>0) { + payProductsService.deleteWithValidByIds(xjids, true); + } + //毛料 + PayMaterialBo materialBo = new PayMaterialBo(); + materialBo.setTenantId(id); + List asEventVos = payMaterialService.queryList(materialBo); + List eids = asEventVos.stream().map( PayMaterialVo::getId).collect(Collectors.toList()); + if(eids!=null&&eids.size()>0) { + payMaterialService.deleteWithValidByIds(eids, true); + } + //员工扣补 + PayButieEmplyeeBo ebBo = new PayButieEmplyeeBo(); + ebBo.setTenantId(id); + List ebVos = payButieEmplyeeService.queryList(ebBo); + List ebids = ebVos.stream().map(PayButieEmplyeeVo::getId).collect(Collectors.toList()); + if(ebids!=null&&ebids.size()>0) { + payButieEmplyeeService.deleteWithValidByIds(ebids, true); + } + //补贴 + PayButieBo btBo = new PayButieBo(); + btBo.setTenantId(id); + List sxtVos = butieService.queryList(btBo); + List sxtids = sxtVos.stream().map(PayButieVo::getId).collect(Collectors.toList()); + if(sxtids!=null&&sxtids.size()>0) { + butieService.deleteWithValidByIds(sxtids, true); + } + //应出勤 + PayRequireAttendanceReportBo acBo = new PayRequireAttendanceReportBo(); + acBo.setTenantId(id); + List acVos = payRequireAttendanceReportService.queryList(acBo); + List acids = acVos.stream().map(PayRequireAttendanceReportVo::getId).collect(Collectors.toList()); + if(acids!=null&&acids.size()>0) { + payRequireAttendanceReportService.deleteWithValidByIds(acids, true); + } + //考勤 + PayAttendanceBo aBo = new PayAttendanceBo(); + aBo.setTenantId(id); + List aVos = payAttendanceService.queryList(aBo); + List aids = aVos.stream().map(PayAttendanceVo::getId).collect(Collectors.toList()); + if(aids!=null&&aids.size()>0) { + payAttendanceService.deleteWithValidByIds(aids, true); + } + //员工 + PayEmployeeInfoBo empBo = new PayEmployeeInfoBo(); + empBo.setTenantId(id); + List empVos = payEmployeeInfoService.queryList(empBo); + List empids = empVos.stream().map(PayEmployeeInfoVo::getId).collect(Collectors.toList()); + if(empids!=null&&empids.size()>0) { + payEmployeeInfoService.deleteWithValidByIds(empids, true); + } + //部门 + SysDept bmBo = new SysDept(); + bmBo.setTenantId(id); + List pjVos = deptService.selectDeptList(bmBo); + List bmids = pjVos.stream().map(SysDept::getDeptId).collect(Collectors.toList()); + if(bmids!=null&&bmids.size()>0) { + for(Long bmid:bmids){ + deptService.deleteDeptById(bmid); + } + } + //------------------------------------------------------------------------------------------------------ + //删除公司订阅信息 + PaySubInfoBo subInfo=new PaySubInfoBo(); + subInfo.setTenantId(id); + List infoVos = subInfoService.queryList(subInfo); + List sids = infoVos.stream().map(PaySubInfoVo::getId).collect(Collectors.toList()); + if(sids!=null&&sids.size()>0){ + subInfoService.deleteWithValidByIds(sids,true); + } + //删除公司下所有用户 + SysUser user = new SysUser(); + user.setTenantId(id); + List users = userService.selectUserList(user); + if(users!=null&&users.size()>0){ + List uids = users.stream().map(SysUser::getUserId).collect(Collectors.toList()); + userService.deleteUserByIds(uids.toArray(uids.toArray(new Long[uids.size()]))); + } + + //删除公司下的所有角色 + SysRole role = new SysRole(); + role.setTenantId(id); + List roles = roleService.selectRoleList(role); + if(roles!=null&&roles.size()>0){ + List rids = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); + roleService.deleteRoleByIds(rids.toArray(rids.toArray(new Long[rids.size()]))); + } + } + return toAjax(payTenantService.deleteWithValidByIds(Arrays.asList(ids), true)); + } +}