From ecb05e470cb1ac8f2fcef5070d7ec5ad24493fda Mon Sep 17 00:00:00 2001 From: chenze <1824191732@qq.com> Date: Fri, 16 Aug 2024 18:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AF=B9=E5=BA=94bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RepairDeviceTypeController.java | 15 ++++++++++++--- .../admin/service/IRepairRelationalService.java | 2 ++ .../service/impl/RepairRelationalServiceImpl.java | 7 +++++++ .../controller/mobile/WxLoginAPIController.java | 4 +++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/shoot-hand/ics-admin/src/main/java/com/ics/admin/controller/RepairDeviceTypeController.java b/shoot-hand/ics-admin/src/main/java/com/ics/admin/controller/RepairDeviceTypeController.java index 4a4f168..79ac030 100644 --- a/shoot-hand/ics-admin/src/main/java/com/ics/admin/controller/RepairDeviceTypeController.java +++ b/shoot-hand/ics-admin/src/main/java/com/ics/admin/controller/RepairDeviceTypeController.java @@ -145,12 +145,14 @@ public class RepairDeviceTypeController extends BaseController { customerStaffService.updateIcsCustomerStaff(staff1); } } - - int i1 = repairRelationalService.deleteByTypeId(repairDeviceType.getId()); if (i1>=0){ + int count = repairRelationalService.selectCountByUserId(repairDeviceType.getStaffId()); - + if (count >0){ + IcsCustomerStaff staff = customerStaffService.selectIcsCustomerStaffById(repairDeviceType.getStaffId()); + return R.error("该"+staff.getUsername()+"已有角色,请先删除对应角色在添加"); + } //保存成功后,添加设备与派单员关联关系 @@ -167,6 +169,13 @@ public class RepairDeviceTypeController extends BaseController { //保存成功后,添加设备与维修人关联关系 for (Long aLong : repairDeviceType.getWorkerId()) { + int count1 = repairRelationalService.selectCountByUserId(aLong); + + if (count1 >0){ + IcsCustomerStaff staff1 = customerStaffService.selectIcsCustomerStaffById(aLong); + + return R.error("该"+staff1.getUsername()+"已有角色,请先删除对应角色在添加"); + } RepairRelational repairRelational1 = new RepairRelational(); repairRelational1.setTypeId(repairDeviceType.getId()); repairRelational1.setUserId(aLong); diff --git a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/IRepairRelationalService.java b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/IRepairRelationalService.java index 7d9e3a5..02ff5ce 100644 --- a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/IRepairRelationalService.java +++ b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/IRepairRelationalService.java @@ -66,4 +66,6 @@ public interface IRepairRelationalService extends IService { List selectWorkerIdByTypeId(Long typeId); Long selectByUserId(Long id); + + int selectCountByUserId(Long staffId); } diff --git a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/RepairRelationalServiceImpl.java b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/RepairRelationalServiceImpl.java index 396a34f..15c29e0 100644 --- a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/RepairRelationalServiceImpl.java +++ b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/RepairRelationalServiceImpl.java @@ -124,4 +124,11 @@ public class RepairRelationalServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); + wrapper.eq("user_id",staffId); + return repairRelationalMapper.selectCount(wrapper); + } } diff --git a/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxLoginAPIController.java b/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxLoginAPIController.java index 9fe10c1..8287d32 100644 --- a/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxLoginAPIController.java +++ b/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxLoginAPIController.java @@ -331,7 +331,9 @@ public class WxLoginAPIController extends BaseController { IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(userId); if (null != customerStaff) { - if (customerStaff.getDataType().equals("3")) customerStaff.setTypeId(repairRelationalService.selectByUserId(customerStaff.getId())); + if (customerStaff.getDataType() !=null && customerStaff.getDataType().equals("3")){ + customerStaff.setTypeId(repairRelationalService.selectByUserId(customerStaff.getId())); + } StaffCustomer staffCustomer = new StaffCustomer(); staffCustomer.setStaffId(userId); List staffCustomers = staffCustomerService.selectStaffCustomerByStaffId(userId);