package com.qianwen.smartman.modules.system.controller; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.qianwen.core.scanner.modular.annotation.GetResource; import com.qianwen.core.scanner.modular.annotation.PostResource; import com.qianwen.core.scanner.modular.stereotype.ApiResource; import com.qianwen.core.tool.api.R; import com.qianwen.core.tool.node.ForestNodeMerger; import com.qianwen.core.tool.utils.Func; import com.qianwen.smartman.common.constant.CommonConstant; import com.qianwen.smartman.common.constant.DateConstant; import com.qianwen.smartman.common.constant.ExcelConstant; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.smartman.modules.cps.convert.CommonGroupConvert; import com.qianwen.smartman.modules.cps.convert.WorkstationConvert; import com.qianwen.smartman.modules.cps.entity.CommonGroup; import com.qianwen.smartman.modules.cps.entity.CommonGroupOfItem; import com.qianwen.smartman.modules.cps.entity.Workstation; import com.qianwen.smartman.modules.cps.service.ICommonGroupOfItemService; import com.qianwen.smartman.modules.cps.service.ICommonGroupService; import com.qianwen.smartman.modules.cps.service.IWorkstationService; import com.qianwen.smartman.modules.cps.vo.WorkstationVO; import com.qianwen.smartman.modules.system.entity.SeriesItem; import com.qianwen.smartman.modules.system.vo.ChartAlarmDataTestVO; import com.qianwen.smartman.modules.system.vo.ChartDataTableVO; import com.qianwen.smartman.modules.system.vo.ChartGanttStatusDataVO; import com.qianwen.smartman.modules.system.vo.ChartMapDataVO; import com.qianwen.smartman.modules.system.vo.ChartNameValueDataVO; import com.qianwen.smartman.modules.system.vo.ChartSelect; import com.qianwen.smartman.modules.system.vo.ChartSeriesDataVO; import com.qianwen.smartman.modules.system.vo.GanttStatusVO; import com.qianwen.smartman.modules.system.vo.ICard; import com.qianwen.smartman.modules.system.vo.TreeTestVO; import com.qianwen.smartman.modules.system.vo.WorkstationChartSeriesDataVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Api(value = "echart数据类型测试", tags = {"echart数据类型测试"}) @ApiResource({"blade-system/test"}) @RestController /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/ChartTestController.class */ public class ChartTestController { private static final Logger log = LoggerFactory.getLogger(ChartTestController.class); public static String[] colors = {"#73D13D", "#FFC53D", "#40A9FF", "#FF4D4F", "#595959"}; private IWorkstationService workstationService; private ICommonGroupService groupService; private ICommonGroupOfItemService commonGroupOfItemService; public ChartTestController(final IWorkstationService workstationService, final ICommonGroupService groupService, final ICommonGroupOfItemService commonGroupOfItemService) { this.workstationService = workstationService; this.groupService = groupService; this.commonGroupOfItemService = commonGroupOfItemService; } @GetResource({"/gauge"}) @ApiOperation("仪表盘数据(键值对)") public R gaugeDataVO() { ChartNameValueDataVO eChartGaugeDataVO = new ChartNameValueDataVO().addValue("SCORE", 50); return R.data(eChartGaugeDataVO); } @PostResource({"/pie"}) @ApiOperation("饼图数据, 键值对") public R pie() { ChartNameValueDataVO eChartGaugeDataVO = new ChartNameValueDataVO().addValue("普管", 1600).addValue("严管", Integer.valueOf((int) ExcelConstant.DEFAULT_DATA_SIZE)).addValue("宽管", 160).addValue("特殊管理", 30); return R.data(eChartGaugeDataVO); } @PostResource({"/colorBlock"}) @ApiOperation("颜色块数据, 名称数据") public R colorBlock() { ChartNameValueDataVO eChartGaugeDataVO = new ChartNameValueDataVO().addValue("某某某总人数", "12345", "人", "#F56C6C").addValue("某某某总人数", "12345", "人", "#F56C6C").addValue("某某某总人数", "12345", "人", "#F56C6C").addValue("某某某总人数", "12345", "人", "#F56C6C").addValue("某某某总人数", "12345", "人", "#F56C6C").addValue("某某某总人数", "12345", "人", "#F56C6C"); return R.data(eChartGaugeDataVO); } @PostResource({"/series"}) @ApiOperation("单图例") public R seriesDataVO() { List xdata = Arrays.asList("张三", "李四", "王五", "小明"); ArrayList arrayList = new ArrayList(); arrayList.add(new SeriesItem("2016", Arrays.asList(Double.valueOf(43.3d), Double.valueOf(85.8d), Double.valueOf(93.7d), 40))); ChartSeriesDataVO eChartSeriesDataVO = new ChartSeriesDataVO(); eChartSeriesDataVO.setSeries(arrayList); eChartSeriesDataVO.setCategories(xdata); return R.data(eChartSeriesDataVO); } @PostResource({"/series2"}) @ApiOperation("多图例") public R series2DataVO() { Workstation workstation = new Workstation(); workstation.setName("张三"); workstation.setCode("1"); Workstation workstation2 = new Workstation(); workstation2.setName("李四"); workstation2.setCode("2"); Workstation workstation3 = new Workstation(); workstation3.setName("王五"); workstation3.setCode("3"); Workstation workstation4 = new Workstation(); workstation4.setName("小明"); workstation4.setCode("4"); List xdata = Arrays.asList(workstation, workstation2, workstation3, workstation4); ArrayList arrayList = new ArrayList(); arrayList.add(new SeriesItem("2016", Arrays.asList(Double.valueOf(43.3d), Double.valueOf(85.8d), Double.valueOf(93.7d), 40))); arrayList.add(new SeriesItem("2017", Arrays.asList(Double.valueOf(83.1d), Double.valueOf(73.4d), Double.valueOf(55.1d), 50))); arrayList.add(new SeriesItem("2018", Arrays.asList(Double.valueOf(86.4d), Double.valueOf(65.2d), Double.valueOf(82.5d), 60))); arrayList.add(new SeriesItem("2019", Arrays.asList(Double.valueOf(72.4d), Double.valueOf(53.9d), Double.valueOf(39.1d), 70))); WorkstationChartSeriesDataVO chartSeriesDataVO = new WorkstationChartSeriesDataVO(); chartSeriesDataVO.generateCategories(xdata); chartSeriesDataVO.setSeries(arrayList); return R.data(chartSeriesDataVO); } @PostResource({"/scatter"}) @ApiOperation("散点图") public R scatterDataVO() { List xdata = Arrays.asList(1, 2, 3, 4); ArrayList arrayList = new ArrayList(); arrayList.add(new SeriesItem("散点1", Arrays.asList(Double.valueOf(43.3d), Double.valueOf(85.8d), Double.valueOf(93.7d), 40))); arrayList.add(new SeriesItem("散点2", Arrays.asList(Double.valueOf(43.3d), Double.valueOf(85.8d), Double.valueOf(93.7d), 40))); ChartSeriesDataVO eChartSeriesDataVO = new ChartSeriesDataVO(); eChartSeriesDataVO.setCategories(xdata); eChartSeriesDataVO.setSeries(arrayList); return R.data(eChartSeriesDataVO); } @PostResource({"/progress"}) @ApiOperation("进度条,环形图, 键值对") public R progressData() { ChartNameValueDataVO eChartGaugeDataVO = new ChartNameValueDataVO().addValue("SCORE", 90, 80); return R.data(eChartGaugeDataVO); } @GetResource({"/map"}) @ApiOperation("地图数据") public R> eChartMapDataVO() { List list = new ArrayList<>(); ChartMapDataVO eChartMapDataVO = new ChartMapDataVO(); eChartMapDataVO.setLat(Double.valueOf(31.89d)); eChartMapDataVO.setLng(Double.valueOf(121.15d)); eChartMapDataVO.setValue(9); eChartMapDataVO.setName("坐标1"); list.add(eChartMapDataVO); ChartMapDataVO eChartMapDataVO2 = new ChartMapDataVO(); eChartMapDataVO2.setLat(Double.valueOf(39.608266d)); eChartMapDataVO2.setLng(Double.valueOf(109.781327d)); eChartMapDataVO2.setValue(50); eChartMapDataVO2.setName("坐标2"); list.add(eChartMapDataVO2); ChartMapDataVO eChartMapDataVO3 = new ChartMapDataVO(); eChartMapDataVO3.setLat(Double.valueOf(37.35d)); eChartMapDataVO3.setLng(Double.valueOf(120.38d)); eChartMapDataVO3.setValue(12); eChartMapDataVO3.setName("坐标3"); list.add(eChartMapDataVO3); return R.data(list); } @GetResource({"/gantt"}) @ApiOperation("甘特图状态数据") public R ganttStatusDataVO() throws IOException { ClassPathResource classPathResource = new ClassPathResource("/static/json.txt"); InputStreamReader reader = new InputStreamReader(classPathResource.getInputStream()); BufferedReader br = new BufferedReader(reader); String ganttData = ""; while (true) { String line = br.readLine(); if (line != null) { ganttData = ganttData + line; } else { ChartGanttStatusDataVO chartGanttStatusDataVO = new ChartGanttStatusDataVO(); List> seriesItems = (List) JSONArray.parseArray(ganttData).stream().map(item -> { JSONObject json = (JSONObject) item; String name = json.getJSONObject("workStation").getString("workStationName"); List collect = (List) json.getJSONArray("recordItems").stream().map(record -> { JSONObject jsonObject = (JSONObject) record; String startTime = Func.formatDate(new Date()) + jsonObject.getString("startTime").substring(10); String endTime = Func.formatDate(new Date()) + jsonObject.getString("endTime").substring(10); GanttStatusVO ganttStatusVo = new GanttStatusVO(new Timestamp(Func.parseDate(startTime, DateConstant.PATTERN_DATE_TIME).getTime()), new Timestamp(Func.parseDate(endTime, DateConstant.PATTERN_DATE_TIME).getTime()), jsonObject.getInteger("iotStatus")); return ganttStatusVo; }).collect(Collectors.toList()); return new SeriesItem(name, collect); }).collect(Collectors.toList()); chartGanttStatusDataVO.setSeries(seriesItems); chartGanttStatusDataVO.addColorStatus("#FA554C", 1, "报警状态"); chartGanttStatusDataVO.addColorStatus("#F8BB09", 2, "手动模式等待"); chartGanttStatusDataVO.addColorStatus("#FFEC00", 3, "自动模式等待"); chartGanttStatusDataVO.addColorStatus("#FEFF98", 4, "其他模式等待"); chartGanttStatusDataVO.addColorStatus("#2A9F0C", 5, "手动模式运行"); chartGanttStatusDataVO.addColorStatus("#7ED321", 6, "自动模式运行"); chartGanttStatusDataVO.addColorStatus("#9CFF30", 7, "其他模式运行"); chartGanttStatusDataVO.addColorStatus("#696969", 8, "离线"); chartGanttStatusDataVO.addColorStatus("#C0C0C0", 9, "网络断线"); return R.data(chartGanttStatusDataVO); } } } @GetResource({"/table"}) @ApiOperation("表格数据") public R tableDataVO(@RequestParam int length) { List list = this.workstationService.list(Lambda.create().limit(Integer.valueOf(length))); List workstationVOList = list.stream().map(item -> { return WorkstationConvert.INSTANCE.convert(item); }).collect(Collectors.toList()); ChartDataTableVO chartDataTableVO = new ChartDataTableVO(); chartDataTableVO.setData(workstationVOList); chartDataTableVO.addHeader("id", "主键").addHeader("avatar", "工位图片").addHeader("code", "编号").addHeader("name", "名称"); return R.data(chartDataTableVO); } @GetResource({"/select"}) @ApiOperation("下拉测试") public R> getSelectData() { List list = new ArrayList<>(); list.add(new SelectTestVO("设备TOP10", "1")); list.add(new SelectTestVO("设备TOP20", "2")); list.add(new SelectTestVO("设备TOP50", "3")); list.add(new SelectTestVO("设备TOP100", "4")); return R.data(list); } @GetResource({"/tree"}) @ApiOperation("树数据测试") public R> getTreeSelectVO() { List list = this.groupService.list(Wrappers.lambdaQuery().orderByAsc(CommonGroup::getSort)); /* List list = this.groupService.list((Wrapper) Wrappers.lambdaQuery().orderByAsc((v0) -> { return v0.getSort(); }));*/ List vos = list.stream().map(item -> { return CommonGroupConvert.INSTANCE.convertToChart(item); }).collect(Collectors.toList()); List groupIds = list.stream().map((v0) -> { return v0.getId(); }).collect(Collectors.toList()); List itemList = this.commonGroupOfItemService.list(Wrappers.lambdaQuery() .in(Func.isNotEmpty(groupIds), CommonGroupOfItem::getGroupId, groupIds) .eq(CommonGroupOfItem::getGroupType, "group_workstation")); /* List itemList = this.commonGroupOfItemService.list((Wrapper) Wrappers.lambdaQuery().in(Func.isNotEmpty(groupIds), (v0) -> { return v0.getGroupId(); }, groupIds).eq((v0) -> { return v0.getGroupType(); }, CommonGroupConstant.WORKSTATION_TYPE));*/ List workstations = this.workstationService.list(Wrappers.lambdaQuery().eq(Workstation::getStatus, CommonConstant.ENABLE)); /* List workstations = this.workstationService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getStatus(); }, CommonConstant.ENABLE));*/ List workstationList = workstations.stream().map(work -> { TreeTestVO treeTestVO = null; CommonGroupOfItem commonGroupOfItem = itemList.stream().filter(item2 -> { return item2.getItemId().equals(work.getId()); }).findFirst().orElse(null); if (commonGroupOfItem != null) { treeTestVO = new TreeTestVO(); treeTestVO.setName(work.getName()); treeTestVO.setId(work.getId()); treeTestVO.setParentId(commonGroupOfItem.getGroupId()); treeTestVO.setGroup(false); } return treeTestVO; }).filter(item2 -> { return item2 != null; }).collect(Collectors.toList()); vos.addAll(workstationList); List merge = ForestNodeMerger.merge(vos); return R.data(merge); } @PostResource({"/alarmCard"}) @ApiOperation("设备报警卡片(轮播组件) 数据格式") public R alarmCard() { ChartDataTableVO chartDataTableVO = new ChartDataTableVO(); List list = new ArrayList<>(); list.add(new ChartAlarmDataTestVO("设备1", "编号1", "xxxxxx1产生异常报警")); list.add(new ChartAlarmDataTestVO("设备1", "编号2", "xxxxxx2产生异常报警")); list.add(new ChartAlarmDataTestVO("设备1", "编号3", "xxxxxx3产生异常报警")); list.add(new ChartAlarmDataTestVO("设备2", "编号2", "xxxxxx4产生异常报警")); list.add(new ChartAlarmDataTestVO("设备2", "编号2", "xxxxxx5产生异常报警")); list.add(new ChartAlarmDataTestVO("设备2", "编号2", "xxxxxx6产生异常报警")); list.add(new ChartAlarmDataTestVO("设备3", "编号3", "xxxxxx7产生异常报警")); list.add(new ChartAlarmDataTestVO("设备3", "编号3", "xxxxxx8产生异常报警")); chartDataTableVO.setData(list).addHeader("code", "报警编码").addHeader("detail", "报警详情"); return R.data(chartDataTableVO); } @GetResource({"/workSelect"}) @ApiOperation("下拉测试") public R> workSelect() { List list = this.workstationService.list(Wrappers.lambdaQuery().eq(Workstation::getStatus, CommonConstant.ENABLE)); /* List list = this.workstationService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getStatus(); }, CommonConstant.ENABLE));*/ List workstationVOList = list.stream().map(item -> { return WorkstationConvert.INSTANCE.convert(item); }).collect(Collectors.toList()); return R.data(workstationVOList); } /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/ChartTestController$WorkStationQueryVO.class */ public static class WorkStationQueryVO { private List workStationList; public void setWorkStationList(final List workStationList) { this.workStationList = workStationList; } public boolean equals(final Object o) { if (o == this) { return true; } if (o instanceof WorkStationQueryVO) { WorkStationQueryVO other = (WorkStationQueryVO) o; if (other.canEqual(this)) { Object this$workStationList = getWorkStationList(); Object other$workStationList = other.getWorkStationList(); return this$workStationList == null ? other$workStationList == null : this$workStationList.equals(other$workStationList); } return false; } return false; } protected boolean canEqual(final Object other) { return other instanceof WorkStationQueryVO; } public int hashCode() { Object $workStationList = getWorkStationList(); int result = (1 * 59) + ($workStationList == null ? 43 : $workStationList.hashCode()); return result; } public String toString() { return "ChartTestController.WorkStationQueryVO(workStationList=" + getWorkStationList() + ")"; } public List getWorkStationList() { return this.workStationList; } } /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/ChartTestController$SelectTestVO.class */ public class SelectTestVO implements ChartSelect { private String name; private String id; public void setName(final String name) { this.name = name; } public void setId(final String id) { this.id = id; } public boolean equals(final Object o) { if (o == this) { return true; } if (o instanceof SelectTestVO) { SelectTestVO other = (SelectTestVO) o; if (other.canEqual(this)) { Object this$name = getName(); Object other$name = other.getName(); if (this$name == null) { if (other$name != null) { return false; } } else if (!this$name.equals(other$name)) { return false; } Object this$id = getId(); Object other$id = other.getId(); return this$id == null ? other$id == null : this$id.equals(other$id); } return false; } return false; } protected boolean canEqual(final Object other) { return other instanceof SelectTestVO; } public int hashCode() { Object $name = getName(); int result = (1 * 59) + ($name == null ? 43 : $name.hashCode()); Object $id = getId(); return (result * 59) + ($id == null ? 43 : $id.hashCode()); } public String toString() { return "ChartTestController.SelectTestVO(name=" + getName() + ", id=" + getId() + ")"; } public SelectTestVO(final String name, final String id) { this.name = name; this.id = id; } public String getName() { return this.name; } public String getId() { return this.id; } @Override // org.springblade.modules.system.vo.ChartSelect public String getLabel() { return this.name; } @Override // org.springblade.modules.system.vo.ChartSelect public String getValue() { return this.id; } } }