|
|
@@ -0,0 +1,174 @@
|
|
|
+package com.jjt.biz.controller;
|
|
|
+
|
|
|
+import com.jjt.biz.domain.DeviceChannels;
|
|
|
+import com.jjt.biz.domain.DeviceConfig;
|
|
|
+import com.jjt.biz.domain.FlowsRecord;
|
|
|
+import com.jjt.biz.domain.HouseConfig;
|
|
|
+import com.jjt.biz.service.IDeviceChannelsService;
|
|
|
+import com.jjt.biz.service.IDeviceConfigService;
|
|
|
+import com.jjt.biz.service.IFlowsRecordService;
|
|
|
+import com.jjt.biz.service.IHouseConfigService;
|
|
|
+import com.jjt.common.core.controller.BaseController;
|
|
|
+import com.jjt.common.utils.SecurityUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 可视化首页
|
|
|
+ *
|
|
|
+ * @author wukai
|
|
|
+ * @date 2025-10-12
|
|
|
+ */
|
|
|
+@Api(tags = "可视化首页")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/index")
|
|
|
+public class IndexController extends BaseController {
|
|
|
+ @Resource
|
|
|
+ private IHouseConfigService houseConfigService;
|
|
|
+ @Resource
|
|
|
+ private IDeviceConfigService deviceConfigService;
|
|
|
+ @Resource
|
|
|
+ private IDeviceChannelsService channelsService;
|
|
|
+ @Resource
|
|
|
+ private IFlowsRecordService flowsRecordService;
|
|
|
+
|
|
|
+ @ApiOperation("仓库列表")
|
|
|
+ @GetMapping("/house")
|
|
|
+ public List<HouseConfig> house() {
|
|
|
+ HouseConfig houseConfig = new HouseConfig();
|
|
|
+ houseConfig.setDeptId(getDeptId());
|
|
|
+ System.err.println(getDeptId());
|
|
|
+ houseConfig.getParams().put("deptId", getDeptId());
|
|
|
+ return houseConfigService.selectHouseConfigList(houseConfig);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("事件统计")
|
|
|
+ @GetMapping("/events")
|
|
|
+ public Map<String, Object> event() {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Map<String, Object> curr = new HashMap<>();
|
|
|
+ curr.put("0", 0);
|
|
|
+ curr.put("189", 1);
|
|
|
+ curr.put("191", 2);
|
|
|
+ curr.put("195", 3);
|
|
|
+ curr.put("201", 4);
|
|
|
+ result.put("curr", curr);
|
|
|
+ Map<String, Object> month = new HashMap<>();
|
|
|
+ month.put("0", 0);
|
|
|
+ month.put("189", 45);
|
|
|
+ month.put("191", 12);
|
|
|
+ month.put("195", 22);
|
|
|
+ month.put("201", 55);
|
|
|
+ result.put("month", month);
|
|
|
+ List<Map<String, Object>> trade = new ArrayList<>();
|
|
|
+ // 模拟数据:从1号到今天的事件统计
|
|
|
+ int today = LocalDate.now().getDayOfMonth();
|
|
|
+ // 获取今天是几号
|
|
|
+ for (int i = 1; i <= today; i++) {
|
|
|
+ Map<String, Object> dayData = new HashMap<>();
|
|
|
+ dayData.put("date", "2025-10-" + String.format("%02d", i));
|
|
|
+ dayData.put("value", (int) (Math.random() * 100));
|
|
|
+ // 随机事件数
|
|
|
+ trade.add(dayData);
|
|
|
+ }
|
|
|
+ result.put("trade", trade);
|
|
|
+ List<Map<String, Object>> flow = new ArrayList<>();
|
|
|
+ for (int i = 1; i <= today; i++) {
|
|
|
+ Map<String, Object> dayData = new HashMap<>();
|
|
|
+ dayData.put("date", "2025-10-" + String.format("%02d", i));
|
|
|
+
|
|
|
+ int total = (int) (Math.random() * 100) + 50;
|
|
|
+ // 总量(闭单量+未闭单量)
|
|
|
+ int closed = (int) (Math.random() * total);
|
|
|
+ // 闭单量
|
|
|
+ int unclosed = total - closed;
|
|
|
+ // 未闭单量
|
|
|
+
|
|
|
+ dayData.put("total", total);
|
|
|
+ dayData.put("closed", closed);
|
|
|
+ dayData.put("unclosed", unclosed);
|
|
|
+
|
|
|
+ // 随机流程数
|
|
|
+ flow.add(dayData);
|
|
|
+ }
|
|
|
+ result.put("flow", flow);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据流程ID查询流程列表")
|
|
|
+ @GetMapping("/flows/{flowId}")
|
|
|
+ public List<FlowsRecord> flowsList(@PathVariable("flowId") String flowId) {
|
|
|
+ FlowsRecord flowsRecord = new FlowsRecord();
|
|
|
+ flowsRecord.setUpdateBy(flowId + "");
|
|
|
+ return flowsRecordService.selectFlowsRecordList(flowsRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据流程ID和仓库ID查询流程列表")
|
|
|
+ @GetMapping("/flows/{flowId}/{houseId}")
|
|
|
+ public List<FlowsRecord> flowsHouseList(@PathVariable("flowId") String flowId, @PathVariable("houseId") Long houseId) {
|
|
|
+ FlowsRecord flowsRecord = new FlowsRecord();
|
|
|
+ flowsRecord.setUpdateBy(flowId + "");
|
|
|
+ HouseConfig houseConfig = houseConfigService.selectHouseConfigByHouseId(houseId);
|
|
|
+ flowsRecord.setHouse(houseConfig.getHouseName());
|
|
|
+ return flowsRecordService.selectFlowsRecordList(flowsRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据仓库ID查询设备列表")
|
|
|
+ @GetMapping("/device/{houseId}")
|
|
|
+ public List<DeviceChannels> device(@PathVariable("houseId") Long houseId) {
|
|
|
+ DeviceConfig deviceConfig = new DeviceConfig();
|
|
|
+ deviceConfig.setHouseId(houseId);
|
|
|
+ deviceConfig.getParams().put("deptId", SecurityUtils.getDeptId());
|
|
|
+ List<DeviceConfig> list = deviceConfigService.selectDeviceConfigList(deviceConfig);
|
|
|
+ List<DeviceChannels> channels = new ArrayList<>();
|
|
|
+ for (DeviceConfig device : list) {
|
|
|
+ channelsService.findByCode(device.getDeviceCode()).forEach(channels::add);
|
|
|
+ }
|
|
|
+ return channels;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据仓库ID查询事件统计")
|
|
|
+ @GetMapping("/event/{houseId}")
|
|
|
+ public Map<String, Object> flow(@PathVariable("houseId") Long houseId) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Map<String, Object> curr = new HashMap<>();
|
|
|
+ curr.put("0", 0);
|
|
|
+ curr.put("189", 1);
|
|
|
+ curr.put("191", 2);
|
|
|
+ curr.put("195", 3);
|
|
|
+ curr.put("201", 4);
|
|
|
+ result.put("curr", curr);
|
|
|
+ int today = LocalDate.now().getDayOfMonth();
|
|
|
+ List<Map<String, Object>> flow = new ArrayList<>();
|
|
|
+ for (int i = 1; i <= today; i++) {
|
|
|
+ Map<String, Object> dayData = new HashMap<>();
|
|
|
+ dayData.put("date", "2025-10-" + String.format("%02d", i));
|
|
|
+ int total = (int) (Math.random() * 100) + 50;
|
|
|
+ // 总量(闭单量+未闭单量)
|
|
|
+ int closed = (int) (Math.random() * total);
|
|
|
+ // 闭单量
|
|
|
+ int unclosed = total - closed;
|
|
|
+ // 未闭单量
|
|
|
+
|
|
|
+ dayData.put("total", total);
|
|
|
+ dayData.put("closed", closed);
|
|
|
+ dayData.put("unclosed", unclosed);
|
|
|
+
|
|
|
+ // 随机流程数
|
|
|
+ flow.add(dayData);
|
|
|
+ }
|
|
|
+ result.put("flow", flow);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|