设备移交
This commit is contained in:
@@ -34,6 +34,11 @@ public class CsDeviceUserPO extends BaseEntity {
|
||||
@TableField(value = "sub_user_id")
|
||||
@ApiModelProperty(value="子用户id")
|
||||
private String subUserId;
|
||||
/**
|
||||
* 状态(0:删除 1:正常)
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 装置Id
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CsEquipmentTransferPO extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态(0:删除 1:未注册 2:注册 3:接入)
|
||||
* 状态(0:删除 1:正常 2:通过审核)
|
||||
*/
|
||||
@TableField(value = "`status`")
|
||||
private Integer status;
|
||||
|
||||
@@ -45,6 +45,8 @@ public class ProjectEquipmentVO {
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
@ApiModelProperty(value = "是否是主用户0-否,1-是")
|
||||
private String isPrimaryUser;
|
||||
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class CsEquipmentTransferPOController extends BaseController {
|
||||
@ApiOperation("设备转移申请通过")
|
||||
@ApiImplicitParam(name = "ids", value = "设备转移申请id", required = true)
|
||||
public HttpResult<Boolean> pass(@RequestParam("ids") List<String> ids){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
String methodDescribe = getMethodDescribe("pass");
|
||||
|
||||
Boolean flag = csEquipmentTransferPOService.pass (ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
|
||||
@@ -80,4 +80,37 @@ public class DeviceUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/transfer")
|
||||
@ApiOperation("设备转移(直接扫码不用申请)")
|
||||
@ApiImplicitParam(name = "eid", value = "设备Id", required = true)
|
||||
public HttpResult<Boolean> transfer(@RequestParam("eid") String eid){
|
||||
String methodDescribe = getMethodDescribe("transfer");
|
||||
|
||||
Boolean flag = csDeviceUserPOService.transfer (eid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("设备删除")
|
||||
@ApiImplicitParam(name = "eid", value = "设备Id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam("eid") String eid){
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
|
||||
Boolean flag = csDeviceUserPOService.delete (eid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/cancelShare")
|
||||
@ApiOperation("取消分享")
|
||||
@ApiImplicitParam(name = "eid", value = "设备Id", required = true)
|
||||
public HttpResult<Boolean> cancelShare(@RequestParam("eid") String eid){
|
||||
String methodDescribe = getMethodDescribe("cancelShare");
|
||||
|
||||
Boolean flag = csDeviceUserPOService.cancelShare (eid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,12 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
Boolean share(String id);
|
||||
|
||||
DevCountVO devCount(String id);
|
||||
}
|
||||
|
||||
String isPrimaryUser(String deviceId);
|
||||
|
||||
Boolean transfer(String eid);
|
||||
|
||||
Boolean delete(String eid);
|
||||
|
||||
Boolean cancelShare(String eid);
|
||||
}
|
||||
|
||||
@@ -32,4 +32,12 @@ public interface CsEquipmentTransferPOService extends IService<CsEquipmentTransf
|
||||
* @Date: 2023/5/17
|
||||
*/
|
||||
Boolean pass(List<String> ids);
|
||||
}
|
||||
/**
|
||||
* @Description: 设备转移(直接扫码不用申请)
|
||||
* @Param:
|
||||
* @return: java.lang.Boolean
|
||||
* @Author: clam
|
||||
* @Date: 2023/7/25
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
@@ -28,6 +29,8 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Objects.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -48,7 +51,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(String id) {
|
||||
CsDeviceUserPO one = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, id).one();
|
||||
if(!Objects.isNull(one)){
|
||||
if(!isNull(one)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.LOSE_EFFICACY);
|
||||
}
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
@@ -57,6 +60,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
csDevice.setDeviceId(id);
|
||||
csDevice.setPrimaryUserId(userIndex);
|
||||
csDevice.setSubUserId(userIndex);
|
||||
csDevice.setStatus("1");
|
||||
boolean save = this.save(csDevice);
|
||||
return save;
|
||||
}
|
||||
@@ -64,14 +68,14 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean share(String id) {
|
||||
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, id).list();
|
||||
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, id).eq(CsDeviceUserPO::getStatus,"1" ).list();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.DATA_LOSE);
|
||||
|
||||
}
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
CsDeviceUserPO one = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, id).eq(CsDeviceUserPO::getSubUserId,userIndex).one();
|
||||
if(!Objects.isNull(one)){
|
||||
CsDeviceUserPO one = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, id).eq(CsDeviceUserPO::getStatus,"1" ).eq(CsDeviceUserPO::getSubUserId,userIndex).one();
|
||||
if(!isNull(one)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.REPEAT_SHARE);
|
||||
}
|
||||
CsDeviceUserPO csDeviceUserPO = list.get(0);
|
||||
@@ -134,4 +138,80 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
|
||||
return devCountVO;
|
||||
}
|
||||
/**
|
||||
* @Description: 判断当前用户是否是主用户 0-否1-是
|
||||
* @Param:
|
||||
* @return: java.lang.String
|
||||
* @Author: clam
|
||||
* @Date: 2023/7/25
|
||||
*/
|
||||
@Override
|
||||
public String isPrimaryUser(String deviceId) {
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
CsDeviceUserPO one = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, deviceId).eq(CsDeviceUserPO::getStatus,"1" ).eq(CsDeviceUserPO::getPrimaryUserId, userIndex).one();
|
||||
String number = Objects.isNull(one) ? "0" : "1";
|
||||
return number;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean transfer(String eid) {
|
||||
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).list();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.DATA_LOSE);
|
||||
|
||||
}
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"0"));
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
list.forEach(temp->{
|
||||
temp.setPrimaryUserId(userIndex);
|
||||
temp.setStatus("1");
|
||||
if(temp.getPrimaryUserId().equals(temp.getSubUserId())){
|
||||
temp.setSubUserId(userIndex);
|
||||
}
|
||||
});
|
||||
this.saveBatch(list) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean delete(String eid) {
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus, "1").eq(CsDeviceUserPO::getPrimaryUserId, userIndex).list();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.DATA_LOSE);
|
||||
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPO =new CsEquipmentDeliveryPO();
|
||||
csEquipmentDeliveryPO.setId(eid);
|
||||
csEquipmentDeliveryPO.setRunStatus(0);
|
||||
csEquipmentDeliveryMapper.updateById(csEquipmentDeliveryPO);
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"0"));
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @Description: 主用户发起取消分享,则可选择取消拥有该设备权限的子用户。子用户发起取消分享则只是移除自己拥有该设备权限
|
||||
* @Param:
|
||||
* @return: java.lang.Boolean
|
||||
* @Author: clam
|
||||
* @Date: 2023/7/25
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean cancelShare(String eid) {
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
//主用户
|
||||
if(Objects.equals(isPrimaryUser(eid),"1")){
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).ne(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0"));
|
||||
}
|
||||
//子用户
|
||||
else if (Objects.equals(isPrimaryUser(eid),"0")) {
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0"));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -63,6 +64,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final ICsLedgerService csLedgerService;
|
||||
|
||||
private final RoleEngineerDevService roleEngineerDevService;
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -115,6 +117,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
|
||||
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device);
|
||||
list.getRecords().stream().forEach(temp->{
|
||||
temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId()));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,26 @@ package com.njcn.csdevice.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentTransferPOMapper;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentTransferAddParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentTransferPO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentTransferPOService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,7 +36,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CsEquipmentTransferPOServiceImpl extends ServiceImpl<CsEquipmentTransferPOMapper, CsEquipmentTransferPO> implements CsEquipmentTransferPOService{
|
||||
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean add(CsEquipmentTransferAddParm csEquipmentTransferAddParm) {
|
||||
@@ -47,14 +56,26 @@ public class CsEquipmentTransferPOServiceImpl extends ServiceImpl<CsEquipmentTra
|
||||
|
||||
ids.forEach(id -> {
|
||||
CsEquipmentTransferPO csEquipmentTransferPO = this.getById(id);
|
||||
String equipmentIds = csEquipmentTransferPO.getEquipmentIds();
|
||||
String[] split = equipmentIds.split(",");
|
||||
// csEquipmentTransferPO.getEventType().equals()
|
||||
if(!Objects.isNull(csEquipmentTransferPO.getProjectId())){
|
||||
|
||||
}
|
||||
if(!Objects.isNull(csEquipmentTransferPO.getEquipmentIds())){
|
||||
String equipmentIds = csEquipmentTransferPO.getEquipmentIds();
|
||||
String[] split = equipmentIds.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
csDeviceUserPOService.transfer(split[i]);
|
||||
}
|
||||
}
|
||||
|
||||
csEquipmentTransferPO.setStatus(2);
|
||||
this.updateById(csEquipmentTransferPO);
|
||||
log.info("更新成功");
|
||||
|
||||
});
|
||||
|
||||
return null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
csDeviceUserPOQueryWrapper.and(wq -> {
|
||||
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
@@ -112,7 +112,7 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
csDeviceUserPOQueryWrapper.and(wq -> {
|
||||
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
|
||||
Reference in New Issue
Block a user