diff --git a/ics-admin/src/main/java/com/ics/admin/controller/BuildingController.java b/ics-admin/src/main/java/com/ics/admin/controller/BuildingController.java index 8e820a2..999dca5 100644 --- a/ics-admin/src/main/java/com/ics/admin/controller/BuildingController.java +++ b/ics-admin/src/main/java/com/ics/admin/controller/BuildingController.java @@ -59,7 +59,6 @@ public class BuildingController extends BaseController { @PostMapping("save") public R addSave(@RequestBody Building building) { // Park park = parkService.getById(1L); - building.setParkId(1L); return toAjax(buildingService.insertBuilding(building)); } diff --git a/ics-admin/src/main/java/com/ics/admin/controller/CustomerController.java b/ics-admin/src/main/java/com/ics/admin/controller/CustomerController.java index df51ab6..b08063d 100644 --- a/ics-admin/src/main/java/com/ics/admin/controller/CustomerController.java +++ b/ics-admin/src/main/java/com/ics/admin/controller/CustomerController.java @@ -226,8 +226,6 @@ public class CustomerController extends BaseController { // if (User.isAdmin(getCurrentUserId())) { // return R.error("不允许超级管理员用户修改"); // } - customer.setParkId(1L); - customer.setTenantId(1L); ValidatorUtils.validateEntity(customer); customer.setUpdateBy(getLoginName()); return toAjax(customerService.updateCustomer(customer)); diff --git a/ics-admin/src/main/java/com/ics/admin/controller/CustomerStaffController.java b/ics-admin/src/main/java/com/ics/admin/controller/CustomerStaffController.java index 9a1176b..4d4cf65 100644 --- a/ics-admin/src/main/java/com/ics/admin/controller/CustomerStaffController.java +++ b/ics-admin/src/main/java/com/ics/admin/controller/CustomerStaffController.java @@ -118,8 +118,6 @@ public class CustomerStaffController extends BaseController { if (customerId != null && !"".equals(customerId)) { icsCustomerStaff.setIcsCustomerId(Long.valueOf(customerId)); } -// Integer customerId = getLoginCustomerId(); -// icsCustomerStaff.setIcsCustomerId(customerId.longValue()); icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT); return result(icsCustomerStaffService.selectIcsCustomerStaffList(icsCustomerStaff)); } @@ -132,9 +130,7 @@ public class CustomerStaffController extends BaseController { if (customerId != null && !"".equals(customerId)) { icsCustomerStaff.setIcsCustomerId(Long.valueOf(customerId)); } -// Integer customerId = getLoginCustomerId(); -// icsCustomerStaff.setIcsCustomerId(customerId.longValue()); -// icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF); + return result(icsCustomerStaffService.getStaffListNotId(icsCustomerStaff)); } @@ -194,52 +190,39 @@ public class CustomerStaffController extends BaseController { @Ignore @PostMapping("updateStaff") public R updateStaff(@RequestBody IcsCustomerStaff icsCustomerStaff) { - IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(Long.valueOf(icsCustomerStaff.getMobile())); - if (customerStaff != null) { - customerStaff.setIcsCustomerId(Long.valueOf(icsCustomerStaff.getCustomerId())); - ArrayList ids = new ArrayList<>(); - //根据企业id 查询对应的房间 - Customer customer = customerService.selectCustomerById(Long.valueOf(icsCustomerStaff.getCustomerId())); + IcsCustomerStaff customerStaff = icsCustomerStaffService.selectByPhone(icsCustomerStaff.getMobile()); + customerStaff.setName(icsCustomerStaff.getName()); + customerStaff.setMobile(icsCustomerStaff.getMobile()); + customerStaff.setGender(icsCustomerStaff.getGender()); + customerStaff.setPhoto(icsCustomerStaff.getPhoto()); + customerStaff.setAvatar(icsCustomerStaff.getAvatar()); + customerStaff.setUsername(icsCustomerStaff.getUsername()); + customerStaff.setCardNo(icsCustomerStaff.getCardNo()); + customerStaff.setAddress(icsCustomerStaff.getAddress()); + customerStaff.setEmail(icsCustomerStaff.getEmail()); + customerStaff.setDegree(icsCustomerStaff.getDegree()); + customerStaff.setUrgent(icsCustomerStaff.getUrgent()); - if (customer != null) { - String roomId = customer.getRoomId(); - List roomIds = StrUtil.split(roomId, ','); - List collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList()); - for (Long roomid : collect) { - Room room = roomService.selectRoomById(roomid); - if (null != room) { - Long id = room.getId(); - RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id); - if (null != roomEquipment) { - ids.add(roomEquipment.getEquipmentId()); - } - List detailEquipments = detailEquipmentService.selectByRoomId(id); - if (CollUtil.isNotEmpty(detailEquipments)) { - for (DetailEquipment detailEquipment : detailEquipments) { - ids.add(detailEquipment.getEquipmentId()); - } - } - } - } - } + //如果修改了照片,根据企业找到对应的房间,根据房间找到对应的设备,添加用户照片进入设备中 - if (CollUtil.isNotEmpty(ids)) { - for (Long id : ids) { + Long icsCustomerId = customerStaff.getIcsCustomerId(); + Customer customer = customerService.selectCustomerById(icsCustomerId); + String roomId = customer.getRoomId(); + List roomIds = StrUtil.split(roomId, ','); + List collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList()); + //获取了房间集合,循环对应集合, + for (Long aLong : collect) { + //根据房间id获取设备id + List roomEquipments = roomEquipmentService.selectListByRoomId(aLong); + for (RoomEquipment roomEquipment : roomEquipments) { + //根据设备id获取设备 + Equipment equipment = equipmentService.selectEquipmentById(roomEquipment.getEquipmentId()); - UserEquipment userEquipment = new UserEquipment(); - userEquipment.setEquipmentId(id); - userEquipment.setUserId(Long.valueOf(icsCustomerStaff.getMobile())); - userEquipment.setStartTime(customer.getStartDate()); - userEquipment.setEndDate(customer.getEndDate()); - userEquipmentService.insertUserEquipment(userEquipment); - } } } - - customerStaff.setUpdateTime(new Date()); return toAjax(icsCustomerStaffService.updateIcsCustomerStaff(customerStaff)); } @@ -362,8 +345,6 @@ public class CustomerStaffController extends BaseController { } } } - - if (CollUtil.isNotEmpty(ids)) { List equipment = equipmentService.selectListByIds(ids); List equipment1 = selectEquipmentListByIds(equipment); @@ -428,16 +409,32 @@ public class CustomerStaffController extends BaseController { @RequiresPermissions("meeting:roomContent:list") @PostMapping("/saveUserEquipment") public R saveUserEquipment(@RequestBody UserEquipment equipment) { + + if (equipment.getUserId() != null) { + + int num = userEquipmentService.selectListByUserId(equipment.getUserId()); + if (num > 0) { + int count = userEquipmentService.deleteUserEquipmentByUserId(equipment.getUserId()); + Assert.isTrue(count > 0, "删除失败"); + } + + } + + for (Long id : equipment.getUserIds()) { UserEquipment userEquipment = new UserEquipment(); userEquipment.setEquipmentId(id); userEquipment.setUserId(equipment.getUserId()); - Customer customer = customerService.selectCustomerById(equipment.getUserId()); - if (customer != null) { - userEquipment.setStartTime(customer.getStartDate()); - userEquipment.setEndDate(customer.getEndDate()); + IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId()); + if (null != customerStaff) { + Customer customer = customerService.selectCustomerById(customerStaff.getId()); + if (customer != null) { + userEquipment.setStartTime(customer.getStartDate()); + userEquipment.setEndDate(customer.getEndDate()); + } } + userEquipmentService.insertUserEquipment(userEquipment); } return R.ok(); diff --git a/ics-admin/src/main/java/com/ics/admin/controller/meeting/EquipmentController.java b/ics-admin/src/main/java/com/ics/admin/controller/meeting/EquipmentController.java index 832a70f..c1eb8af 100644 --- a/ics-admin/src/main/java/com/ics/admin/controller/meeting/EquipmentController.java +++ b/ics-admin/src/main/java/com/ics/admin/controller/meeting/EquipmentController.java @@ -411,8 +411,13 @@ public class EquipmentController extends BaseController { public R saveDevice(@RequestBody UserEquipment userEquipment) { if (userEquipment.getId() != null) { - int count = userEquipmentService.deleteUserEquipmentByEquipmentId(userEquipment.getId()); - Assert.isTrue(count > 0, "删除失败"); + + int num = userEquipmentService.selectListByEquipmentId(userEquipment.getId()); + if (num > 0) { + int count = userEquipmentService.deleteUserEquipmentByEquipmentId(userEquipment.getId()); + Assert.isTrue(count > 0, "删除失败"); + } + } for (Long id : userEquipment.getUserIds()) { diff --git a/ics-admin/src/main/java/com/ics/admin/service/impl/RoomEquipmentServiceImpl.java b/ics-admin/src/main/java/com/ics/admin/service/impl/RoomEquipmentServiceImpl.java index 47ad52c..74a6cf2 100644 --- a/ics-admin/src/main/java/com/ics/admin/service/impl/RoomEquipmentServiceImpl.java +++ b/ics-admin/src/main/java/com/ics/admin/service/impl/RoomEquipmentServiceImpl.java @@ -123,4 +123,11 @@ public class RoomEquipmentServiceImpl extends ServiceImpl selectListByRoomId(Long aLong) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("room_id",aLong); + return roomEquipmentMapper.selectList(wrapper); + } } diff --git a/ics-admin/src/main/java/com/ics/admin/service/impl/UserEquipmentServiceImpl.java b/ics-admin/src/main/java/com/ics/admin/service/impl/UserEquipmentServiceImpl.java index 958dfd7..0033077 100644 --- a/ics-admin/src/main/java/com/ics/admin/service/impl/UserEquipmentServiceImpl.java +++ b/ics-admin/src/main/java/com/ics/admin/service/impl/UserEquipmentServiceImpl.java @@ -219,6 +219,27 @@ public class UserEquipmentServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); + wrapper.eq("equipment_id", id); + return userEquipmentMapper.selectCount(wrapper); + } + + @Override + public int deleteUserEquipmentByUserId(Long userId) { + UpdateWrapper wrapper = new UpdateWrapper<>(); + wrapper.eq("user_id", userId); + return userEquipmentMapper.delete(wrapper); + } + + @Override + public int selectListByUserId(Long userId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", userId); + return userEquipmentMapper.selectCount(wrapper); + } + public void updateDeviceDataSource(List equipments) { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); diff --git a/ics-admin/src/main/java/com/ics/admin/service/meeting/IRoomEquipmentService.java b/ics-admin/src/main/java/com/ics/admin/service/meeting/IRoomEquipmentService.java index eadf52e..1cfef8b 100644 --- a/ics-admin/src/main/java/com/ics/admin/service/meeting/IRoomEquipmentService.java +++ b/ics-admin/src/main/java/com/ics/admin/service/meeting/IRoomEquipmentService.java @@ -66,4 +66,6 @@ public interface IRoomEquipmentService extends IService { RoomEquipment selectByEquipmentIdAndRoomId(RoomEquipment roomEquipment); RoomEquipment selectByRoomId(Long id); + + List selectListByRoomId(Long aLong); } diff --git a/ics-admin/src/main/java/com/ics/admin/service/meeting/IUserEquipmentService.java b/ics-admin/src/main/java/com/ics/admin/service/meeting/IUserEquipmentService.java index 795c1f3..8838b2d 100644 --- a/ics-admin/src/main/java/com/ics/admin/service/meeting/IUserEquipmentService.java +++ b/ics-admin/src/main/java/com/ics/admin/service/meeting/IUserEquipmentService.java @@ -66,4 +66,10 @@ public interface IUserEquipmentService extends IService { UserEquipment selectUserAndEquipment(Long userId, Long id); int selectCountByUserIdAndDeviceId(UserEquipment userEquipment1); + + int selectListByEquipmentId(Long id); + + int deleteUserEquipmentByUserId(Long userId); + + int selectListByUserId(Long userId); } diff --git a/ics-common/ics-common-core/src/main/java/com/ics/common/core/domain/IcsCustomerStaff.java b/ics-common/ics-common-core/src/main/java/com/ics/common/core/domain/IcsCustomerStaff.java index bb7ef1d..e613899 100644 --- a/ics-common/ics-common-core/src/main/java/com/ics/common/core/domain/IcsCustomerStaff.java +++ b/ics-common/ics-common-core/src/main/java/com/ics/common/core/domain/IcsCustomerStaff.java @@ -20,15 +20,15 @@ public class IcsCustomerStaff extends BaseEntity { private static final long serialVersionUID = 1L; /** 姓名 */ - @Excel(name = "微信昵称",type = Excel.Type.EXPORT) + @Excel(name = "微信昵称") private String username; - @Excel(name = "姓名",type = Excel.Type.EXPORT) + @Excel(name = "姓名") private String name; private String photo; - @Excel(name = "地址",type = Excel.Type.EXPORT) + @Excel(name = "地址") private String address; @Excel(name = "邮箱")