代码优化
This commit is contained in:
@@ -14,11 +14,6 @@ import java.util.List;
|
||||
|
||||
public interface ICsDevModelService {
|
||||
|
||||
/**
|
||||
* 初始化缓存模板信息
|
||||
*/
|
||||
void refreshDevModelCache();
|
||||
|
||||
/**
|
||||
* 解析模板文件->入库
|
||||
* @param file
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -77,11 +78,6 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
private final ICsTopicService csTopicService;
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void refreshDevModelCache() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void addModel(MultipartFile file) {
|
||||
@@ -299,20 +295,33 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||
}
|
||||
CsDevModelPO model = new CsDevModelPO();
|
||||
model.setDevTypeName(templateDto.getDevType());
|
||||
model.setName(templateDto.getDevType());
|
||||
model.setVersionNo(templateDto.getVersion());
|
||||
model.setVersionDate(Date.valueOf(templateDto.getTime()));
|
||||
model.setFilePath(filePath);
|
||||
model.setStatus ("1");
|
||||
// CsDevModelPO model = new CsDevModelPO();
|
||||
// model.setDevTypeName(templateDto.getDevType());
|
||||
// model.setName(templateDto.getDevType());
|
||||
// model.setVersionNo(templateDto.getVersion());
|
||||
// model.setVersionDate(Date.valueOf(templateDto.getTime()));
|
||||
// model.setFilePath(filePath);
|
||||
// model.setStatus ("1");
|
||||
// //fixme 先用数据类型来区分模板的类型
|
||||
// if (templateDto.getDataList().contains("Apf") || templateDto.getDataList().contains("Dvr")){
|
||||
// model.setType(0);
|
||||
// } else {
|
||||
// model.setType(1);
|
||||
// }
|
||||
// csDevModelMapper.insert(model);
|
||||
CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
||||
csDevModelAddParm.setDevTypeName(templateDto.getDevType());
|
||||
csDevModelAddParm.setName(templateDto.getDevType());
|
||||
csDevModelAddParm.setVersionNo(templateDto.getVersion());
|
||||
csDevModelAddParm.setVersionDate(Date.valueOf(templateDto.getTime()));
|
||||
csDevModelAddParm.setFilePath(filePath);
|
||||
//fixme 先用数据类型来区分模板的类型
|
||||
if (templateDto.getDataList().contains("Apf") || templateDto.getDataList().contains("Dvr")){
|
||||
model.setType(0);
|
||||
csDevModelAddParm.setType(0);
|
||||
} else {
|
||||
model.setType(1);
|
||||
csDevModelAddParm.setType(1);
|
||||
}
|
||||
csDevModelMapper.insert(model);
|
||||
CsDevModelPO model = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.mapper.OverlimitMapper;
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.dto.CsModelDto;
|
||||
@@ -540,7 +539,9 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
boolean result = false;
|
||||
Map<Integer,String> modelMap = new HashMap<>();
|
||||
try {
|
||||
//删除缓存数据
|
||||
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
||||
redisUtil.deleteKeysByString(AppRedisKey.DEV_MODEL);
|
||||
//询问装置当前所用模板
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid,new Gson().toJson(getJson(mid,TypeEnum.TYPE_3.getCode())),1,false);
|
||||
//接收到模板,判断模板是否存在,替换模板,发起接入
|
||||
|
||||
Reference in New Issue
Block a user