xiongan-meeting/ics-admin/src/main/java/com/ics/admin/controller/CustomerStaffController.java

236 lines
8.2 KiB
Java
Raw Normal View History

2024-02-25 11:16:55 +08:00
package com.ics.admin.controller;
2024-03-29 08:55:47 +08:00
import cn.hutool.core.collection.CollUtil;
2024-03-24 16:48:09 +08:00
import cn.hutool.core.lang.Assert;
2024-03-29 08:55:47 +08:00
import com.ics.admin.domain.Customer;
import com.ics.admin.domain.Room;
import com.ics.admin.domain.meeting.*;
import com.ics.admin.service.ICustomerService;
2024-02-25 11:16:55 +08:00
import com.ics.admin.service.IIcsCustomerStaffService;
2024-03-29 08:55:47 +08:00
import com.ics.admin.service.IRoomService;
import com.ics.admin.service.meeting.IDetailEquipmentService;
import com.ics.admin.service.meeting.IRoomContentService;
import com.ics.admin.service.meeting.IRoomEquipmentService;
import com.ics.admin.service.meeting.IUserEquipmentService;
2024-02-25 11:16:55 +08:00
import com.ics.common.constant.Constants;
import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.IcsCustomerStaff;
2024-02-25 11:16:55 +08:00
import com.ics.common.core.domain.R;
import com.ics.system.domain.User;
import com.ics.system.service.IUserService;
2024-02-25 11:16:55 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
2024-03-24 16:48:09 +08:00
import org.wf.jwtp.annotation.Ignore;
2024-02-25 11:16:55 +08:00
import org.wf.jwtp.annotation.RequiresPermissions;
2024-03-29 08:55:47 +08:00
import java.util.ArrayList;
2024-02-25 11:16:55 +08:00
import java.util.Date;
2024-03-26 09:53:05 +08:00
import java.util.List;
2024-02-25 11:16:55 +08:00
/**
* 企业员工 提供者
*
* @author ics
* @date 2024-02-19
*/
@RestController
@RequestMapping("/admin/staff")
public class CustomerStaffController extends BaseController {
2024-02-25 11:16:55 +08:00
private final static String ACCESS_USERID = Constants.ACCESS_USERID;
@Autowired
private IIcsCustomerStaffService icsCustomerStaffService;
@Autowired
private IUserService userService;
2024-02-25 11:16:55 +08:00
2024-03-29 08:55:47 +08:00
@Autowired
private ICustomerService customerService;
@Autowired
private IRoomContentService roomContentService;
@Autowired
private IRoomService roomService;
@Autowired
private IRoomEquipmentService roomEquipmentService;
@Autowired
private IDetailEquipmentService detailEquipmentService;
@Autowired
private IUserEquipmentService userEquipmentService;
2024-02-25 11:16:55 +08:00
/**
* 查询企业员工
*/
@GetMapping("get/{id}")
public IcsCustomerStaff get(@PathVariable("id") Long id) {
return icsCustomerStaffService.selectIcsCustomerStaffById(id);
}
/**
* 查询企业员工列表
*/
@RequiresPermissions("admin:staff:list")
@GetMapping("list")
public R list(IcsCustomerStaff icsCustomerStaff) {
startPage();
2024-03-24 16:48:09 +08:00
String customerId = icsCustomerStaff.getCustomerId();
if (customerId != null && !"".equals(customerId)) {
icsCustomerStaff.setIcsCustomerId(Long.valueOf(customerId));
}
// Integer customerId = getLoginCustomerId();
// icsCustomerStaff.setIcsCustomerId(customerId.longValue());
// icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
2024-02-25 11:16:55 +08:00
return result(icsCustomerStaffService.selectIcsCustomerStaffList(icsCustomerStaff));
}
2024-03-24 16:48:09 +08:00
@Ignore
@GetMapping("getStaffListNotId")
public R getStaffListNotId(IcsCustomerStaff icsCustomerStaff) {
startPage();
String customerId = icsCustomerStaff.getCustomerId();
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));
}
2024-03-26 09:53:05 +08:00
@Ignore
@GetMapping("getStaffListByUser")
public R getStaffListByUser(IcsCustomerStaff icsCustomerStaff) {
startPage();
String customerId = icsCustomerStaff.getCustomerId();
if (customerId != null && !"".equals(customerId)) {
icsCustomerStaff.setIcsCustomerId(Long.valueOf(customerId));
}
List<IcsCustomerStaff> staffListByUser = icsCustomerStaffService.getStaffListByUser(icsCustomerStaff);
if (icsCustomerStaff.getStaffId() != null){
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(icsCustomerStaff.getStaffId());
if (null != customerStaff){
staffListByUser.add(customerStaff);
}
}
return result(staffListByUser);
}
2024-02-25 11:16:55 +08:00
/**
* 新增保存企业员工
*/
@RequiresPermissions("admin:staff:add")
@PostMapping("save")
public R addSave(@RequestBody IcsCustomerStaff icsCustomerStaff) {
2024-03-24 16:48:09 +08:00
2024-02-25 11:16:55 +08:00
icsCustomerStaff.setCreateTime(new Date());
icsCustomerStaff.setCreateBy(getLoginName());
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
return toAjax(i);
2024-02-25 11:16:55 +08:00
}
/**
* 修改保存企业员工
*/
2024-03-26 09:53:05 +08:00
@Ignore
2024-02-25 11:16:55 +08:00
@PostMapping("update")
public R editSave(@RequestBody IcsCustomerStaff icsCustomerStaff) {
2024-03-24 16:48:09 +08:00
2024-03-29 08:55:47 +08:00
2024-02-25 11:16:55 +08:00
icsCustomerStaff.setUpdateTime(new Date());
2024-03-29 08:55:47 +08:00
return toAjax(icsCustomerStaffService.updateIcsCustomerStaff(icsCustomerStaff));
}
/**
* 新增企业员工
* @param icsCustomerStaff
* @return
*/
@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<Long> ids = new ArrayList<>();
//根据企业id 查询对应的房间
Customer customer = customerService.selectCustomerById(Long.valueOf(icsCustomerStaff.getCustomerId()));
if (customer !=null ){
Room room = roomService.selectRoomById(customer.getRoomId());
if (null != room) {
Long id = room.getId();
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
if (null != roomEquipment) {
ids.add(roomEquipment.getEquipmentId());
}
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
if (CollUtil.isNotEmpty(detailEquipments)) {
for (DetailEquipment detailEquipment : detailEquipments) {
ids.add(detailEquipment.getEquipmentId());
}
}
}
}
if (CollUtil.isNotEmpty(ids)) {
for (Long id : ids) {
UserEquipment equipment = userEquipmentService.selectUserAndEquipment(Long.valueOf(icsCustomerStaff.getMobile()), id);
if (null == equipment) {
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());
2024-03-24 16:48:09 +08:00
return toAjax(icsCustomerStaffService.updateIcsCustomerStaff(customerStaff));
2024-02-25 11:16:55 +08:00
}
2024-03-29 08:55:47 +08:00
/**
* 删除企业员工
* @param icsCustomerStaff
* @return
*/
@Ignore
@PostMapping("updateStaffByCustomer")
public R updateStaffByCustomer(@RequestBody IcsCustomerStaff icsCustomerStaff) {
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(Long.valueOf(icsCustomerStaff.getId()));
customerStaff.setUpdateTime(new Date());
return toAjax(icsCustomerStaffService.updateByCustomer(customerStaff));
}
2024-02-25 11:16:55 +08:00
/**
* 删除企业员工
*/
@RequiresPermissions("admin:staff:remove")
@PostMapping("remove")
public R remove(String ids) {
return toAjax(icsCustomerStaffService.deleteIcsCustomerStaffByIds(ids));
}
2024-02-25 11:16:55 +08:00
}