提交
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.csdevice.api;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.EquipmentFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@@ -23,5 +24,5 @@ public interface EquipmentFeignClient {
|
||||
@PostMapping("/updateStatusBynDid")
|
||||
HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status);
|
||||
@PostMapping("/queryEquipmentById")
|
||||
HttpResult<List<CsEquipmentDeliveryPO>> queryDeviceById(@RequestParam("ids") List<String> ids);
|
||||
HttpResult<List<CsEquipmentDeliveryDTO>> queryDeviceById(@RequestParam("ids") List<String> ids);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
@@ -42,7 +43,7 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> queryDeviceById(List<String> ids) {
|
||||
public HttpResult<List<CsEquipmentDeliveryDTO>> queryDeviceById(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询出厂设备详情",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public enum AlgorithmResponseEnum {
|
||||
LOSE_EFFICACY ("A00509","二维码失效,该设备已绑定"),
|
||||
DATA_LOSE ("A00510","未找到设备与主用户信息"),
|
||||
REPEAT_SHARE ("A00511","设备已分享完成,请勿再次分享"),
|
||||
DEVICE_LOSE("A00512","设备id缺失")
|
||||
|
||||
DEVICE_LOSE("A00512","设备id缺失"),
|
||||
CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除");
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2023/3/30 16:23【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* 设备出厂表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CsEquipmentDeliveryDTO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableField(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 网关识别码
|
||||
*/
|
||||
@TableField(value = "ndid")
|
||||
private String ndid;
|
||||
|
||||
/**
|
||||
* 装置mac地址
|
||||
*/
|
||||
@TableField(value = "mac")
|
||||
private String mac;
|
||||
|
||||
/**
|
||||
* 装置用途(治理、监测...)
|
||||
*/
|
||||
// @TableField(value = "dev_use")
|
||||
// private String devUse;
|
||||
|
||||
/**
|
||||
* 装置类型(直连设备、网关设备、装置)
|
||||
*/
|
||||
@TableField(value = "dev_type")
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 装置型号(pqs588、pqs680...)
|
||||
*/
|
||||
@TableField(value = "dev_model")
|
||||
private String devModel;
|
||||
|
||||
/**
|
||||
* 装置接入方式(mqtt、cloud)
|
||||
*/
|
||||
@TableField(value = "dev_access_method")
|
||||
private String devAccessMethod;
|
||||
|
||||
/**
|
||||
* 装置程序版本
|
||||
*/
|
||||
@TableField(value = "program_version")
|
||||
private String programVersion;
|
||||
|
||||
/**
|
||||
* 调试人员
|
||||
*/
|
||||
@TableField(value = "debug_person")
|
||||
private String debugPerson;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 合同号
|
||||
*/
|
||||
@TableField(value = "cntract_no")
|
||||
private String cntractNo;
|
||||
|
||||
/**
|
||||
* 营销经理
|
||||
*/
|
||||
@TableField(value = "sales_manager")
|
||||
private String salesManager;
|
||||
|
||||
/**
|
||||
* 接入状态(1:未注册 2:注册 3:接入)
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 设备状态(0:删除 1:离线 2:在线)
|
||||
*/
|
||||
@TableField(value = "run_status")
|
||||
private Integer runStatus;
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||
@@ -24,10 +25,12 @@ import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -121,10 +124,15 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
@PostMapping("/queryEquipmentById")
|
||||
@ApiOperation("设备查询通过id获取")
|
||||
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> queryEquipmentById(@RequestParam List<String> ids){
|
||||
public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids){
|
||||
String methodDescribe = getMethodDescribe("queryEquipmentById");
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryPOS, methodDescribe);
|
||||
List<CsEquipmentDeliveryDTO> collect = csEquipmentDeliveryPOS.stream().map(temp -> {
|
||||
CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = new CsEquipmentDeliveryDTO();
|
||||
BeanUtils.copyProperties(temp, csEquipmentDeliveryDTO);
|
||||
return csEquipmentDeliveryDTO;
|
||||
}).collect(Collectors.toList());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, collect, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
@@ -133,6 +136,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
devCountVO.setId(id);
|
||||
//
|
||||
devCountVO.setEventCount(0);
|
||||
devCountVO.setAlarmLineCount(data.size());
|
||||
//todo重寫 offLineCount AlarmLineCount
|
||||
devCountVO.setOffLineCount(0);
|
||||
|
||||
@@ -156,21 +160,16 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean transfer(String eid) {
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
|
||||
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) ;
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).apply("primary_user_id=sub_user_id").set(CsDeviceUserPO::getPrimaryUserId,userIndex).set(CsDeviceUserPO::getSubUserId,userIndex).update();
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).apply("primary_user_id<>sub_user_id").set(CsDeviceUserPO::getPrimaryUserId,userIndex).update();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -188,7 +187,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
csEquipmentDeliveryPO.setId(eid);
|
||||
csEquipmentDeliveryPO.setRunStatus(0);
|
||||
csEquipmentDeliveryMapper.updateById(csEquipmentDeliveryPO);
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"0"));
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@@ -204,11 +203,11 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
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"));
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).ne(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
}
|
||||
//子用户
|
||||
else if (Objects.equals(isPrimaryUser(eid),"0")) {
|
||||
this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0"));
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsEngineeringMapper;
|
||||
import com.njcn.csdevice.mapper.CsEngineeringUserMapper;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
@@ -92,9 +94,16 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
CsLedger csLedger1 = new CsLedger();
|
||||
csLedger1.setId(csEngineeringAuditParm.getId());
|
||||
if(Objects.equals("0",csEngineeringAuditParm.getStatus())){
|
||||
QueryWrapper<CsLedger> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status",1).eq("pid",csEngineeringAuditParm.getId());
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(queryWrapper);
|
||||
if(!CollectionUtil.isEmpty(csLedgers)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.CHIRLDREN_EXIST.getMessage());
|
||||
}
|
||||
|
||||
csLedger1.setState(0);
|
||||
|
||||
|
||||
}
|
||||
if(StringUtils.isNotBlank(csEngineeringAuditParm.getName())){
|
||||
csLedger1.setName(csEngineeringAuditParm.getName());
|
||||
|
||||
Reference in New Issue
Block a user