| | |
| | | import java.util.TreeMap; |
| | | |
| | | @Service |
| | | public class DataSourceImpl implements DataSource |
| | | { |
| | | public class DataSourceImpl implements DataSource { |
| | | private static final Logger log = LoggerFactory.getLogger(Class.class); |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取表与标签数量关系 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<Table,Integer> getCount() throws Exception { |
| | | Map<Table,Integer> map = Maps.newHashMap(); |
| | | public Map<Table, Integer> getCount() throws Exception { |
| | | Map<Table, Integer> map = Maps.newHashMap(); |
| | | |
| | | BaseImpl base = new BaseImpl(goldenConfig.getServer()); |
| | | |
| | |
| | | for (int tableId : tableIds) { |
| | | int i = base.getTableRealSizeById(tableId); |
| | | Table table = base.getTablePropertiesById(tableId); |
| | | map.put(table,i); |
| | | map.put(table, i); |
| | | } |
| | | return map; |
| | | } |
| | |
| | | /** |
| | | * k - tableName |
| | | * v - point |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String,List<Point>> selectAllEntity() throws Exception { |
| | | public Map<String, List<Point>> selectAllEntity() throws Exception { |
| | | Map<String, List<Point>> result = Maps.newTreeMap(); |
| | | //Map<Table,List<Point>> result=Maps.newHashMap(); |
| | | |
| | |
| | | |
| | | BaseImpl base = new BaseImpl(goldenConfig.getServer()); |
| | | |
| | | map.forEach((k,v)->{ |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | int[] pointIds = base.search(SearchConditionUtil.getSearchCondition(), |
| | | v, |
| | | DataSort.SORT_BY_ID); |
| | | List<FullPoint> fullPoints = selectFullPoint(pointIds); |
| | | List<Point> points = PointConvert.fullpointsToPointEntity(fullPoints); |
| | | result.put(k.getName(),points); |
| | | }catch (Exception e){ |
| | | result.put(k.getName(), points); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("取数据失败"); |
| | | } |
| | | }); |
| | |
| | | for (Map.Entry<String, List<Point>> entry : tableListMap.entrySet()) { |
| | | String k = entry.getKey(); |
| | | List<Point> v = entry.getValue(); |
| | | insert(k,v); |
| | | insert(k, v); |
| | | |
| | | } |
| | | } |
| | |
| | | KTNZ2C_PLCDao ktnz2CPlcDao; |
| | | |
| | | |
| | | public void insert(String flag,List<Point> point){ |
| | | System.out.println(flag); |
| | | public void insert(String flag, List<Point> point) { |
| | | log.info("golden 中 表 ----> {} 正在构建数据..."); |
| | | TableEnum byType = TableEnum.getByType(flag); |
| | | |
| | | switch (flag) { |
| | | case "SMS": |
| | | point.forEach(p->{ |
| | | SMS data=PointConvert.pointToSMS(p); |
| | | switch (byType) { |
| | | case SMS: |
| | | point.forEach(p -> { |
| | | SMS data = PointConvert.pointToSMS(p); |
| | | smsDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case "DLZ_PLC": |
| | | point.forEach(p->{ |
| | | DLZ_PLC data=PointConvert.pointToDLZPLC(p); |
| | | dlzPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case "DJW_PLC": |
| | | point.forEach(p->{ |
| | | DJW_PLC data=PointConvert.pointToDJWPLC(p); |
| | | djwPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case "BDS_PLC": |
| | | point.forEach(p->{ |
| | | BDS_PLC data=PointConvert.pointToBDSPLC(p); |
| | | case BDS_PLC: |
| | | point.forEach(p -> { |
| | | BDS_PLC data = PointConvert.pointToBDSPLC(p); |
| | | bdsPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case "KTNZ2C_PLC": |
| | | point.forEach(p->{ |
| | | KTNZ2C_PLC data=PointConvert.pointToKTNZ2CPLC(p); |
| | | case DJW_PLC: |
| | | point.forEach(p -> { |
| | | DJW_PLC data = PointConvert.pointToDJWPLC(p); |
| | | djwPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case DLZ_PLC: |
| | | point.forEach(p -> { |
| | | DLZ_PLC data = PointConvert.pointToDLZPLC(p); |
| | | dlzPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | case KTNZ2C_PLC: |
| | | point.forEach(p -> { |
| | | KTNZ2C_PLC data = PointConvert.pointToKTNZ2CPLC(p); |
| | | ktnz2CPlcDao.saveAndFlush(data); |
| | | }); |
| | | break; |
| | | default: |
| | | //TODO:剩下表构建 |
| | | } |
| | | |
| | | } |