7 Commits

Author SHA1 Message Date
hzj
cd07f8bee3 批量新增设备bug修改 2025-05-21 12:18:46 +08:00
xy
58a559b7b7 bug修改 2025-05-20 10:29:47 +08:00
hzj
52342d736d 批量新增设备bug修改 2025-05-19 10:58:35 +08:00
xy
6f5ffb8395 设备列表添加mqtt连接状态属性 2025-04-28 12:42:10 +08:00
hzj
ed7c02a116 批量新增设备bug修改 2025-04-28 09:42:36 +08:00
hzj
e12d23d4e1 批量新增设备bug修改 2025-04-28 08:41:24 +08:00
xy
0965eed31b 功能调整 2025-02-13 13:13:48 +08:00
8 changed files with 54 additions and 21 deletions

View File

@@ -86,6 +86,9 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
@ApiModelProperty(value="装置使用状态(0:停用 1:启用)")
private Integer usageStatus ;
@ApiModelProperty(value="装置与MQTT服务器连接状态")
private String connectStatus ;
private Integer sort;
}

View File

@@ -4,7 +4,9 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
@@ -63,10 +65,8 @@ import java.util.stream.Stream;
public class EquipmentDeliveryController extends BaseController {
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final IMqttUserService mqttUserService;
private final CsDevModelRelationService csDevModelRelationService;
private final DictTreeFeignClient dictTreeFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@@ -178,14 +178,6 @@ public class EquipmentDeliveryController extends BaseController {
public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param){
String methodDescribe = getMethodDescribe("list");
Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param);
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
csEquipmentDeliveryVO.setStatus(5);
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
csEquipmentDeliveryVO.setStatus(6);
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@@ -257,7 +249,18 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping(value = "importEquipment")
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importEquipment");
csEquipmentDeliveryService.importEquipment(file, response);
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response);
if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)){
csEquipmentDeliveryPOS.forEach(temp->{
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(temp.getNdid());
if (result){
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(temp.getNdid());
}
});
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@ResponseBody

View File

@@ -14,7 +14,7 @@
where
pid = #{modelId}
and cl_dev = #{clDev}
and data_type in ('Stat',NULL)
and (data_type = 'Stat' or data_type IS NULL)
order by type,cl_dev
</select>

View File

@@ -99,7 +99,7 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/
CsEquipmentDeliveryPO findDevByNDid(String nDid);
void importEquipment(MultipartFile file, HttpServletResponse response);
List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response);
void delete(String devId);

View File

@@ -18,6 +18,7 @@ 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.access.api.AskDeviceDataFeignClient;
import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
@@ -93,7 +94,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final AskDeviceDataFeignClient askDeviceDataFeignClient;
private final RedisUtil redisUtil;
private final CsSoftInfoMapper csSoftInfoMapper;
private final IMqttUserService mqttUserService;
private final MqttUtil mqttUtil;
@Override
public void refreshDeviceDataCache() {
LambdaQueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new LambdaQueryWrapper<>();
@@ -311,6 +313,22 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
item.setQrPath(item.getQrPath());
}
});
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
csEquipmentDeliveryVO.setStatus(5);
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
csEquipmentDeliveryVO.setStatus(6);
}
//判断装置是否已经连接上mqtt服务器
String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (mqttClient) {
csEquipmentDeliveryVO.setConnectStatus("已连接");
} else {
csEquipmentDeliveryVO.setConnectStatus("未连接");
}
}
return page;
}
@@ -446,7 +464,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
@Transactional(rollbackFor = Exception.class)
public void importEquipment(MultipartFile file, HttpServletResponse response) {
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {
ImportParams params = new ImportParams ( );
params.setHeadRows(1);
params.setTitleRows(1);
@@ -536,6 +554,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentDeliveryPO.setRunStatus(1);
csEquipmentDeliveryPO.setStatus(1);
csEquipmentDeliveryPO.setProcess(2);
csEquipmentDeliveryPO.setSort(100);
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
csEquipmentProcess.setDevId(csEquipmentDeliveryPO.getNdid());
@@ -548,17 +567,20 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}).collect (Collectors.toList ( ));
csEquipmentProcessPOService.saveBatch(collect1,500);
this.saveOrUpdateBatch (collect, 500);
return collect;
}
if (!CollectionUtils.isEmpty (falseCollect)) {
ExportParams exportExcel = new ExportParams ("批量导入模板(请严格按照模板标准填入数据)", "非法设备信息");
Workbook workbook = ExcelExportUtil.exportExcel (exportExcel, DeviceExcelTemplete.IllegalityDeviceExcelTemplete.class, falseCollect);
ExcelStyleUtil.exportFileByWorkbook (workbook, "非法设备信息.xlsx", response);
return null;
}
} catch (Exception e) {
e.printStackTrace ( );
}
return null;
}
/*
* 物理删除设备相关数据

View File

@@ -337,8 +337,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = Objects.isNull(temp.getValue()) ? 3.14159 : temp.getValue() / 1000;
vo.setStatisticalData(Double.valueOf(df.format(re)));
re = Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue() / 1000));
vo.setStatisticalData(re);
unit = "k" + epdPqd.getUnit();
} else {
vo.setStatisticalData(Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue())));

View File

@@ -220,8 +220,8 @@ public class DataServiceImpl implements IDataService {
if (Objects.equals("Primary",dataLevel)) {
if (Objects.equals("Primary",csDataSetLevel)) {
if (HarmonicConstant.POWER_LIST.contains(item2.getShowName())) {
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / 1000;
vo.setAvgValue(Double.valueOf(df.format(re)));
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : Double.parseDouble(df.format(statisticalDataDTO.getValue() / 1000));
vo.setAvgValue(re);
unit = "k" + item2.getUnit();
} else {
vo.setAvgValue(Objects.isNull(statisticalDataDTO) ? 3.14159 : Double.parseDouble(df.format(statisticalDataDTO.getValue())));

View File

@@ -36,6 +36,7 @@ import lombok.RequiredArgsConstructor;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.DecimalFormat;
import java.time.ZoneId;
@@ -273,7 +274,11 @@ public class StableDataServiceImpl implements StableDataService {
List<CsLinePO> finalCsLinePOList = csLinePOList;
data.forEach(epdPqd->{
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
if(StringUtils.isEmpty(commonStatisticalQueryParam.getFrequency())){
frequency ="";
}else {
frequency = "_"+commonStatisticalQueryParam.getFrequency();
}
String finalFrequency1 = frequency;
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
CommonQueryParam commonQueryParam = new CommonQueryParam();