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-04-03 14:28:17 +08:00
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
2024-04-08 11:15:03 +08:00
|
|
|
import cn.hutool.core.date.DateUtil;
|
2024-03-24 16:48:09 +08:00
|
|
|
import cn.hutool.core.lang.Assert;
|
2024-04-03 14:28:17 +08:00
|
|
|
import cn.hutool.core.util.StrUtil;
|
2024-04-08 11:15:03 +08:00
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
import com.ics.admin.domain.*;
|
2024-03-29 08:55:47 +08:00
|
|
|
import com.ics.admin.domain.meeting.*;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.admin.listener.ImportPowerWaterFeeListener;
|
|
|
|
import com.ics.admin.service.*;
|
|
|
|
import com.ics.admin.service.meeting.*;
|
2024-04-03 16:51:12 +08:00
|
|
|
import com.ics.admin.utils.EasyPoiUtils;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.admin.utils.ExcelView;
|
2024-04-03 16:51:12 +08:00
|
|
|
import com.ics.admin.utils.SellerVO;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.admin.vo.ImportPowerWaterFeeVO;
|
2024-02-25 11:16:55 +08:00
|
|
|
import com.ics.common.constant.Constants;
|
|
|
|
import com.ics.common.core.controller.BaseController;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.common.core.domain.BaseEntity;
|
2024-03-13 15:15:35 +08:00
|
|
|
import com.ics.common.core.domain.IcsCustomerStaff;
|
2024-02-25 11:16:55 +08:00
|
|
|
import com.ics.common.core.domain.R;
|
2024-04-08 11:15:03 +08:00
|
|
|
import com.ics.common.core.domain.dto.DevicePersonDto;
|
|
|
|
import com.ics.common.core.domain.dto.FacesDto;
|
|
|
|
import com.ics.common.utils.*;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.common.utils.poi.ExcelUtil;
|
2024-03-09 17:23:55 +08:00
|
|
|
import com.ics.system.domain.User;
|
2024-04-03 14:28:17 +08:00
|
|
|
import com.ics.system.service.ICurrentUserService;
|
2024-03-09 17:23:55 +08:00
|
|
|
import com.ics.system.service.IUserService;
|
2024-04-03 14:28:17 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
|
|
import org.jxls.common.Context;
|
2024-02-25 11:16:55 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-04-03 14:28:17 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2024-02-25 11:16:55 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-04-03 14:28:17 +08:00
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
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-04-03 14:28:17 +08:00
|
|
|
import org.wf.jwtp.util.SubjectUtil;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.net.URLEncoder;
|
2024-04-03 16:51:12 +08:00
|
|
|
import java.text.SimpleDateFormat;
|
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-04-03 14:28:17 +08:00
|
|
|
import java.util.stream.Collectors;
|
2024-02-25 11:16:55 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 企业员工 提供者
|
|
|
|
*
|
|
|
|
* @author ics
|
|
|
|
* @date 2024-02-19
|
|
|
|
*/
|
2024-04-03 14:28:17 +08:00
|
|
|
@Slf4j
|
2024-02-25 11:16:55 +08:00
|
|
|
@RestController
|
|
|
|
@RequestMapping("/admin/staff")
|
2024-02-25 16:43:09 +08:00
|
|
|
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;
|
2024-03-09 17:23:55 +08:00
|
|
|
@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;
|
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
@Autowired
|
|
|
|
private ICurrentUserService currentUserService;
|
|
|
|
|
2024-03-29 08:55:47 +08:00
|
|
|
@Autowired
|
|
|
|
private IRoomEquipmentService roomEquipmentService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IDetailEquipmentService detailEquipmentService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IUserEquipmentService userEquipmentService;
|
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
@Autowired
|
|
|
|
private IEquipmentService equipmentService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IBuildingDetailService buildingDetailService;
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
private static final String BASE64_PREFIX = "data:image/png;base64,";
|
|
|
|
|
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
/**
|
|
|
|
* app的密钥值
|
|
|
|
*/
|
|
|
|
@Value("${dfs.path}")
|
|
|
|
private String path;
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
@Value("${dfs.domain}")
|
|
|
|
private String url;
|
|
|
|
|
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));
|
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT);
|
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));
|
|
|
|
}
|
2024-04-03 16:47:12 +08:00
|
|
|
|
2024-03-24 16:48:09 +08:00
|
|
|
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);
|
2024-04-03 14:28:17 +08:00
|
|
|
if (icsCustomerStaff.getStaffId() != null) {
|
2024-03-26 09:53:05 +08:00
|
|
|
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(icsCustomerStaff.getStaffId());
|
2024-04-03 14:28:17 +08:00
|
|
|
if (null != customerStaff) {
|
2024-03-26 09:53:05 +08:00
|
|
|
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());
|
2024-02-25 16:43:09 +08:00
|
|
|
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
|
2024-03-09 17:23:55 +08:00
|
|
|
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-04-03 14:28:17 +08:00
|
|
|
icsCustomerStaff.setDataType(Constants.CUSTOMER_STAFF);
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增企业员工
|
2024-04-03 14:28:17 +08:00
|
|
|
*
|
2024-03-29 08:55:47 +08:00
|
|
|
* @param icsCustomerStaff
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Ignore
|
|
|
|
@PostMapping("updateStaff")
|
|
|
|
public R updateStaff(@RequestBody IcsCustomerStaff icsCustomerStaff) {
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
//如果没有注册小程序的话
|
|
|
|
String customerId = "";
|
2024-03-29 08:55:47 +08:00
|
|
|
|
2024-04-03 16:47:12 +08:00
|
|
|
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectByPhone(icsCustomerStaff.getMobile());
|
2024-04-08 11:15:03 +08:00
|
|
|
if (customerStaff != null) {
|
|
|
|
|
|
|
|
if (icsCustomerStaff.getId() == null) {
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
|
|
|
|
Customer customer = customerService.selectCustomerById(Long.valueOf(icsCustomerStaff.getCustomerId()));
|
|
|
|
if (null != customer) {
|
|
|
|
String roomId = customer.getRoomId();
|
|
|
|
List<String> roomIds = StrUtil.split(roomId, ',');
|
|
|
|
List<Long> collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
//获取了房间集合,循环对应集合,
|
|
|
|
for (Long id : collect) {
|
|
|
|
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 userEquipment = new UserEquipment();
|
|
|
|
userEquipment.setEquipmentId(id);
|
|
|
|
userEquipment.setUserId(customerStaff.getId());
|
|
|
|
userEquipment.setStartTime(customer.getStartDate());
|
|
|
|
userEquipment.setEndDate(customer.getEndDate());
|
|
|
|
userEquipmentService.insertUserEquipment(userEquipment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 (icsCustomerStaff.getCustomerId() != null) {
|
|
|
|
customerStaff.setIcsCustomerId(Long.valueOf(icsCustomerStaff.getCustomerId()));
|
|
|
|
customerId = icsCustomerStaff.getCustomerId();
|
|
|
|
} else {
|
|
|
|
customerId = customerStaff.getIcsCustomerId().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
Customer customer = customerService.selectCustomerById(Long.valueOf(customerId));
|
|
|
|
if (null != customer) {
|
|
|
|
String roomId = customer.getRoomId();
|
|
|
|
List<String> roomIds = StrUtil.split(roomId, ',');
|
|
|
|
List<Long> collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
//获取了房间集合,循环对应集合,
|
|
|
|
for (Long aLong : collect) {
|
|
|
|
//根据房间id获取设备id
|
|
|
|
List<RoomEquipment> roomEquipments = roomEquipmentService.selectListByRoomId(aLong);
|
|
|
|
for (RoomEquipment roomEquipment : roomEquipments) {
|
|
|
|
//根据设备id获取设备
|
|
|
|
Equipment equipment = equipmentService.selectEquipmentById(roomEquipment.getEquipmentId());
|
|
|
|
if (equipment != null) {
|
|
|
|
String persons = DeviceUtils.queryPersons(String.valueOf(customerStaff.getId()));
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(persons);
|
|
|
|
Integer amount = (Integer) jsonObject.get("amount");
|
|
|
|
if (amount <= 0) {
|
|
|
|
DevicePersonDto devicePersonDto = new DevicePersonDto();
|
|
|
|
ArrayList<FacesDto> facesDtos = new ArrayList<>();
|
|
|
|
devicePersonDto.setPersonId(String.valueOf(customerStaff.getId()));
|
|
|
|
devicePersonDto.setName(customerStaff.getName());
|
|
|
|
devicePersonDto.setPhone(String.valueOf(customerStaff.getMobile()));
|
|
|
|
devicePersonDto.setCertificateType("111");
|
|
|
|
devicePersonDto.setCertificateNumber(customerStaff.getCardNo());
|
|
|
|
//添加人员类型
|
|
|
|
devicePersonDto.setPersonType("whitelist");
|
|
|
|
//添加访客时间
|
|
|
|
FacesDto facesDto = new FacesDto();
|
|
|
|
facesDto.setFaceId(String.valueOf(customerStaff.getId()));
|
|
|
|
String photoUrl = url + customerStaff.getPhoto();
|
|
|
|
String faceData = BASE64_PREFIX + UrlToBase64Util.imageUrlToBase64(photoUrl);
|
|
|
|
facesDto.setData(faceData);
|
|
|
|
facesDtos.add(facesDto);
|
|
|
|
devicePersonDto.setFaces(facesDtos);
|
|
|
|
String s = DeviceUtils.addPersons(equipment.getIp(), devicePersonDto);
|
|
|
|
log.info("添加人员返回结果:" + s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
return toAjax(icsCustomerStaffService.updateIcsCustomerStaff(customerStaff));
|
2024-03-29 08:55:47 +08:00
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
icsCustomerStaff.setDataType("1");
|
|
|
|
icsCustomerStaff.setIcsCustomerId(Long.valueOf(icsCustomerStaff.getCustomerId()));
|
|
|
|
|
|
|
|
return toAjax(icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff));
|
|
|
|
|
2024-02-25 11:16:55 +08:00
|
|
|
}
|
|
|
|
|
2024-03-29 08:55:47 +08:00
|
|
|
/**
|
|
|
|
* 删除企业员工
|
2024-04-03 14:28:17 +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-04-03 14:28:17 +08:00
|
|
|
/**
|
|
|
|
* 删除企业员工
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("admin:staff:remove")
|
|
|
|
@PostMapping("remove")
|
|
|
|
public R remove(String ids) {
|
|
|
|
return toAjax(icsCustomerStaffService.deleteIcsCustomerStaffByIds(ids));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
@GetMapping("selectCustomerStaffList")
|
|
|
|
public R selectCustomerStaffList(IcsCustomerStaff icsCustomerStaff) {
|
|
|
|
startPage();
|
|
|
|
String customerId = icsCustomerStaff.getCustomerId();
|
|
|
|
if (customerId != null && !"".equals(customerId)) {
|
|
|
|
icsCustomerStaff.setIcsCustomerId(Long.valueOf(customerId));
|
|
|
|
}
|
|
|
|
List<IcsCustomerStaff> icsCustomerStaffs = icsCustomerStaffService.selectCustomerStaffList(icsCustomerStaff);
|
|
|
|
for (IcsCustomerStaff customerStaff : icsCustomerStaffs) {
|
|
|
|
//获取设备数量
|
|
|
|
UserEquipment userEquipment = new UserEquipment();
|
|
|
|
userEquipment.setUserId(customerStaff.getId());
|
|
|
|
List<UserEquipment> equipments = userEquipmentService.selectUserEquipmentList(userEquipment);
|
|
|
|
customerStaff.setNum(equipments.size());
|
2024-03-29 08:55:47 +08:00
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
|
|
|
return result(icsCustomerStaffs);
|
|
|
|
}
|
2024-03-29 08:55:47 +08:00
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
// @RequiresPermissions("admin:staff:import")
|
|
|
|
@Ignore
|
|
|
|
@PostMapping("/importData")
|
|
|
|
public R importData(MultipartFile file) throws Exception {
|
|
|
|
// }
|
|
|
|
ExcelUtil<IcsCustomerStaff> util = new ExcelUtil<IcsCustomerStaff>(IcsCustomerStaff.class);
|
|
|
|
List<IcsCustomerStaff> userList = util.importExcel(file.getInputStream());
|
|
|
|
|
|
|
|
boolean isAdmin = SubjectUtil.hasRole(getRequest(), "manager");
|
|
|
|
if (isAdmin) {
|
|
|
|
Long parkId = currentUserService.getParkId();
|
|
|
|
Long tenantId = currentUserService.getTenantId();
|
|
|
|
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
boolean b = SubjectUtil.hasRole(getRequest(), "admin");
|
|
|
|
if (b) {
|
2024-04-08 11:15:03 +08:00
|
|
|
for (IcsCustomerStaff customerStaff : userList) {
|
|
|
|
User user = userService.selectUserById(getCurrentUserId());
|
|
|
|
if (user != null) {
|
|
|
|
customerStaff.setIcsCustomerId(user.getCustomerId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String message = icsCustomerStaffService.importCustomerStaff(userList);
|
|
|
|
return R.data(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
@GetMapping("/exportTemplate")
|
|
|
|
public void exportTemplate (HttpServletResponse response) throws IOException {
|
|
|
|
|
|
|
|
List<SellerVO> sellerVOList = new ArrayList<>();
|
|
|
|
String title = "用户导入数据";
|
|
|
|
String sheetName = "用户导模板";
|
|
|
|
String fileName = sheetName + "-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
|
|
|
|
EasyPoiUtils.exportExcel(sellerVOList, null, sheetName, SellerVO.class, fileName, true, response);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//授权用户设备权限,查询出所有的设备
|
|
|
|
@RequiresPermissions("meeting:roomContent:list")
|
|
|
|
@PostMapping("/selectUserDeviceList")
|
|
|
|
public R selectUserDeviceList () {
|
|
|
|
|
|
|
|
//根据园区 角色 查询所有的设备信息
|
|
|
|
boolean isAdmin = SubjectUtil.hasRole(getRequest(), "manager");
|
|
|
|
if (isAdmin) {
|
|
|
|
Long parkId = currentUserService.getParkId();
|
|
|
|
Long tenantId = currentUserService.getTenantId();
|
|
|
|
Equipment equipment1 = new Equipment();
|
|
|
|
equipment1.setParkId(parkId);
|
|
|
|
equipment1.setTenantId(tenantId);
|
|
|
|
|
|
|
|
//根据园区id 查询所有的设备信息
|
|
|
|
List<Equipment> equipment = equipmentService.selectEquipmentList(equipment1);
|
|
|
|
List<Equipment> equipment2 = selectEquipmentListByIds(equipment);
|
|
|
|
|
|
|
|
return R.data(equipment2);
|
|
|
|
}
|
|
|
|
boolean b = SubjectUtil.hasRole(getRequest(), "admin");
|
|
|
|
if (b) {
|
|
|
|
User user = userService.selectUserById(getCurrentUserId());
|
|
|
|
if (null != user.getCustomerId()) {
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
Customer customer = customerService.selectCustomerById(user.getCustomerId());
|
|
|
|
//根据企业 查询对应的 房间,和对应的楼层
|
|
|
|
String roomId = customer.getRoomId();
|
|
|
|
List<String> roomIds = StrUtil.split(roomId, ',');
|
|
|
|
List<Long> 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<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
|
|
|
if (CollUtil.isNotEmpty(detailEquipments)) {
|
|
|
|
for (DetailEquipment detailEquipment : detailEquipments) {
|
|
|
|
ids.add(detailEquipment.getEquipmentId());
|
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
if (CollUtil.isNotEmpty(ids)) {
|
|
|
|
List<Equipment> equipment = equipmentService.selectListByIds(ids);
|
|
|
|
List<Equipment> equipment1 = selectEquipmentListByIds(equipment);
|
2024-04-03 14:28:17 +08:00
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
return R.data(equipment1);
|
|
|
|
} else {
|
|
|
|
return R.data(new ArrayList<Equipment>());
|
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
|
|
|
|
List<Equipment> equipment = equipmentService.selectEquipmentList(new Equipment());
|
|
|
|
List<Equipment> equipment1 = selectEquipmentListByIds(equipment);
|
|
|
|
return R.data(equipment1);
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
/**
|
|
|
|
* 查询当前用户的所有设备
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("meeting:roomContent:list")
|
|
|
|
@PostMapping("/selectEquipmentListById")
|
|
|
|
public R selectEquipmentListById (@RequestBody UserEquipment equipment){
|
|
|
|
List<UserEquipment> equipments = userEquipmentService.selectUserEquipmentList(equipment);
|
|
|
|
List<Long> collect = equipments.stream().map(UserEquipment::getEquipmentId).collect(Collectors.toList());
|
|
|
|
if (CollUtil.isNotEmpty(collect)) {
|
|
|
|
List<Equipment> equipment1 = equipmentService.selectListByIds(collect);
|
|
|
|
List<Equipment> equipment2 = selectEquipmentListByIds(equipment1);
|
|
|
|
return R.data(equipment2);
|
|
|
|
}
|
|
|
|
return R.data(equipments);
|
2024-03-29 08:55:47 +08:00
|
|
|
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
2024-02-25 11:16:55 +08:00
|
|
|
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
public List<Equipment> selectEquipmentListByIds (List < Equipment > equipment) {
|
|
|
|
for (Equipment equipment2 : equipment) {
|
|
|
|
RoomEquipment roomEquipment = roomEquipmentService.selectByEquipmentId(equipment2.getId());
|
|
|
|
if (roomEquipment != null) {
|
|
|
|
Room room = roomService.selectRoomById(roomEquipment.getRoomId());
|
|
|
|
equipment2.setRoomId(room.getId());
|
|
|
|
equipment2.setBuildId(room.getBuildingDetailId());
|
|
|
|
equipment2.setRoomName(room.getName());
|
|
|
|
BuildingDetail buildingDetail = buildingDetailService.selectBuildingDetailById(room.getBuildingDetailId());
|
2024-04-03 14:28:17 +08:00
|
|
|
if (buildingDetail != null) {
|
|
|
|
equipment2.setBuildName(buildingDetail.getFloorName());
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
} else {
|
|
|
|
DetailEquipment detailEquipment = detailEquipmentService.selectByEquipmentId(equipment2.getId());
|
|
|
|
if (null != detailEquipment) {
|
|
|
|
BuildingDetail buildingDetail = buildingDetailService.selectBuildingDetailById(detailEquipment.getBuildingDetailId());
|
|
|
|
if (buildingDetail != null) {
|
|
|
|
equipment2.setBuildName(buildingDetail.getFloorName());
|
|
|
|
}
|
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
return equipment;
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
2024-04-03 16:47:12 +08:00
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
@RequiresPermissions("meeting:roomContent:list")
|
|
|
|
@PostMapping("/saveUserEquipment")
|
|
|
|
public R saveUserEquipment (@RequestBody UserEquipment equipment){
|
2024-04-03 16:47:12 +08:00
|
|
|
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
//根据企业查询出所有的设备
|
2024-04-03 16:47:12 +08:00
|
|
|
|
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
if (equipment.getUserId() != null) {
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId());
|
|
|
|
if (null != customerStaff) {
|
|
|
|
Customer customer = customerService.selectCustomerById(customerStaff.getIcsCustomerId());
|
|
|
|
//根据企业 查询对应的 房间,和对应的楼层
|
|
|
|
String roomId = customer.getRoomId();
|
|
|
|
List<String> roomIds = StrUtil.split(roomId, ',');
|
|
|
|
List<Long> 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<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
|
|
|
if (CollUtil.isNotEmpty(detailEquipments)) {
|
|
|
|
for (DetailEquipment detailEquipment : detailEquipments) {
|
|
|
|
ids.add(detailEquipment.getEquipmentId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Long id : ids) {
|
|
|
|
int num = userEquipmentService.selectListByUserId(equipment.getUserId());
|
|
|
|
if (num > 0) {
|
|
|
|
int count = userEquipmentService.deleteUserEquipmentByUserId(equipment.getUserId(), id);
|
|
|
|
Assert.isTrue(count > 0, "删除失败");
|
|
|
|
}
|
|
|
|
}
|
2024-04-03 16:47:12 +08:00
|
|
|
}
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
2024-04-08 11:15:03 +08:00
|
|
|
for (Long id : equipment.getUserIds()) {
|
|
|
|
UserEquipment userEquipment = new UserEquipment();
|
|
|
|
userEquipment.setEquipmentId(id);
|
|
|
|
userEquipment.setUserId(equipment.getUserId());
|
|
|
|
IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId());
|
|
|
|
if (null != customerStaff1) {
|
|
|
|
Customer customer = customerService.selectCustomerById(customerStaff1.getId());
|
|
|
|
if (customer != null) {
|
|
|
|
userEquipment.setStartTime(customer.getStartDate());
|
|
|
|
userEquipment.setEndDate(customer.getEndDate());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userEquipmentService.insertUserEquipment(userEquipment);
|
|
|
|
}
|
|
|
|
return R.ok();
|
2024-04-03 14:28:17 +08:00
|
|
|
}
|
2024-03-02 17:13:10 +08:00
|
|
|
|
2024-04-08 11:15:03 +08:00
|
|
|
}
|