完善模板解析功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
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.CsGroupClientFallbackFactory;
|
||||||
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csGroup", fallbackFactory = CsGroupClientFallbackFactory.class,contextId = "csGroup")
|
||||||
|
|
||||||
|
public interface CsGroupFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/getGroup")
|
||||||
|
HttpResult<List<CsGroupVO>> getGroupData(@RequestParam("dataSet") String dataSet);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.njcn.csdevice.api.fallback;
|
||||||
|
|
||||||
|
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.CsGroupFeignClient;
|
||||||
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CsGroupClientFallbackFactory implements FallbackFactory<CsGroupFeignClient> {
|
||||||
|
@Override
|
||||||
|
public CsGroupFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new CsGroupFeignClient() {
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<CsGroupVO>> getGroupData(String dataSet) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","查询分组",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,9 @@ public enum AlgorithmResponseEnum {
|
|||||||
REPEAT_SHARE ("A00511","设备已分享完成,请勿再次分享"),
|
REPEAT_SHARE ("A00511","设备已分享完成,请勿再次分享"),
|
||||||
DEVICE_LOSE("A00512","设备id缺失"),
|
DEVICE_LOSE("A00512","设备id缺失"),
|
||||||
CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除"),
|
CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除"),
|
||||||
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除");
|
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除"),
|
||||||
|
|
||||||
|
DATA_ARRAY_MISSING("A00515","详细数据为空")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ public class DevModelRelationController extends BaseController {
|
|||||||
@PostMapping("/getModelByDevId")
|
@PostMapping("/getModelByDevId")
|
||||||
@ApiOperation("根据装置Id查询模板")
|
@ApiOperation("根据装置Id查询模板")
|
||||||
@ApiImplicitParam(name = "devId", value = "装置id", required = true)
|
@ApiImplicitParam(name = "devId", value = "装置id", required = true)
|
||||||
public HttpResult<CsDevModelRelationPO> getModelByDevId(@RequestParam("devId") String devId){
|
public HttpResult<List<CsDevModelRelationPO>> getModelByDevId(@RequestParam("devId") String devId){
|
||||||
String methodDescribe = getMethodDescribe("getModelByDevId");
|
String methodDescribe = getMethodDescribe("getModelByDevId");
|
||||||
CsDevModelRelationPO po = csDevModelRelationService.findModelByDevId(devId);
|
List<CsDevModelRelationPO> list = csDevModelRelationService.findModelByDevId(devId);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
from
|
from
|
||||||
cs_data_array t0
|
cs_data_array t0
|
||||||
where
|
where
|
||||||
pid = #{id}
|
pid = #{id} and (stat_method = 'avg' or stat_method is null)
|
||||||
group by
|
group by
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -44,6 +44,6 @@ public interface CsDevModelRelationService extends IService<CsDevModelRelationPO
|
|||||||
* @param devId
|
* @param devId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CsDevModelRelationPO findModelByDevId(String devId);
|
List<CsDevModelRelationPO> findModelByDevId(String devId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.csdevice.service.impl;
|
package com.njcn.csdevice.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||||
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||||
@@ -40,6 +41,10 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
|||||||
public List<DeviceManagerDetailVO> getTargetById(String id) {
|
public List<DeviceManagerDetailVO> getTargetById(String id) {
|
||||||
List<DeviceManagerDetailVO> list = new ArrayList<>();
|
List<DeviceManagerDetailVO> list = new ArrayList<>();
|
||||||
List<String> l = this.baseMapper.getDictData(id).stream().map(CsDataArray::getDataId).collect(Collectors.toList());
|
List<String> l = this.baseMapper.getDictData(id).stream().map(CsDataArray::getDataId).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(l)){
|
||||||
|
log.error(AlgorithmResponseEnum.DATA_ARRAY_MISSING.getMessage());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
List<EleEpdPqd> result = epdFeignClient.selectByIds(l).getData();
|
List<EleEpdPqd> result = epdFeignClient.selectByIds(l).getData();
|
||||||
Map<String,List<EleEpdPqd>> map = result.stream().collect(Collectors.groupingBy(EleEpdPqd::getShowName,LinkedHashMap::new,Collectors.toList()));
|
Map<String,List<EleEpdPqd>> map = result.stream().collect(Collectors.groupingBy(EleEpdPqd::getShowName,LinkedHashMap::new,Collectors.toList()));
|
||||||
for (Map.Entry<String, List<EleEpdPqd>> entry : map.entrySet()) {
|
for (Map.Entry<String, List<EleEpdPqd>> entry : map.entrySet()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.csdevice.service.impl;
|
package com.njcn.csdevice.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.excel.util.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csdevice.mapper.CsDataSetMapper;
|
import com.njcn.csdevice.mapper.CsDataSetMapper;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||||
@@ -7,6 +8,7 @@ import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
|||||||
import com.njcn.csdevice.service.ICsDataSetService;
|
import com.njcn.csdevice.service.ICsDataSetService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +24,12 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CsDataSet> findDataSetByModelId(String modelId) {
|
public List<CsDataSet> findDataSetByModelId(String modelId) {
|
||||||
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).list();
|
List<CsDataSet> list = new ArrayList<>();
|
||||||
|
list = this.lambdaQuery().eq(CsDataSet::getPid,modelId).eq(CsDataSet::getType,0).list();
|
||||||
|
if (CollectionUtils.isEmpty(list)){
|
||||||
|
list = this.lambdaQuery().eq(CsDataSet::getPid,modelId).orderByAsc(CsDataSet::getClDev).list();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class CsDevModelRelationServiceImpl extends ServiceImpl<CsDevModelRelatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CsDevModelRelationPO findModelByDevId(String devId) {
|
public List<CsDevModelRelationPO> findModelByDevId(String devId) {
|
||||||
return this.lambdaQuery().eq(CsDevModelRelationPO::getDevId,devId).eq(CsDevModelRelationPO::getStatus,1).one();
|
return this.lambdaQuery().eq(CsDevModelRelationPO::getDevId,devId).eq(CsDevModelRelationPO::getStatus,1).list();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
|||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
@@ -28,7 +29,6 @@ import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
|||||||
import com.njcn.csdevice.service.*;
|
import com.njcn.csdevice.service.*;
|
||||||
import com.njcn.db.constant.DbConstant;
|
import com.njcn.db.constant.DbConstant;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -193,8 +193,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
|
DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
|
||||||
List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>();
|
List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>();
|
||||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId,deviceId).one();
|
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId,deviceId).one();
|
||||||
String modelId = csDevModelRelationService.findModelByDevId(deviceId).getModelId();
|
List<CsDevModelRelationPO> list = csDevModelRelationService.findModelByDevId(deviceId);
|
||||||
List<CsDataSet> dataSet = csDataSetService.findDataSetByModelId(modelId);
|
List<CsDataSet> dataSet = new ArrayList<>();
|
||||||
|
list.forEach(item->{
|
||||||
|
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId()));
|
||||||
|
});
|
||||||
BeanUtils.copyProperties(csEquipmentDeliveryPo,deviceManagerVo);
|
BeanUtils.copyProperties(csEquipmentDeliveryPo,deviceManagerVo);
|
||||||
dataSet.forEach(item->{
|
dataSet.forEach(item->{
|
||||||
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
|
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
private List<CsGroupVO> getChildrenes(String tabId, List<CsGroupVO> all) {
|
private List<CsGroupVO> getChildrenes(String tabId, List<CsGroupVO> all) {
|
||||||
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
//fixme 目前组的数据插入写在这里,先查询数据集是否分组,分组了直接查询,没分组先分组再展示数据。后期根据业务需求在做调整
|
//如果未做分组,则先分组
|
||||||
public List<CsGroupVO> insertGroupData(String dataSet) {
|
public List<CsGroupVO> insertGroupData(String dataSet) {
|
||||||
AtomicReference<Integer> sort = new AtomicReference<>(0);
|
AtomicReference<Integer> sort = new AtomicReference<>(0);
|
||||||
List<CsGroup> ls = new ArrayList<>();
|
List<CsGroup> ls = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user