فهرست منبع

首页相关接口

wukai 1 ماه پیش
والد
کامیت
b181627ad4

+ 174 - 0
jjt-admin/src/main/java/com/jjt/biz/controller/IndexController.java

@@ -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;
+    }
+}

+ 2 - 101
jjt-admin/src/main/java/com/jjt/biz/domain/DeviceConfig.java

@@ -3,6 +3,7 @@ package com.jjt.biz.domain;
 import com.baomidou.mybatisplus.annotation.TableId;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.jjt.common.annotation.Excel;
@@ -15,6 +16,7 @@ import com.jjt.common.core.domain.BaseEntity;
  * @date 2025-10-14
  */
 @ApiModel(value = "DeviceConfig", description = "视频融合配置")
+@Data
 public class DeviceConfig extends BaseEntity{
     private static final long serialVersionUID = 1L;
 
@@ -63,105 +65,4 @@ public class DeviceConfig extends BaseEntity{
     @Excel(name = "状态")
     private String status;
 
-    public void setAutoId(Long autoId)
-    {
-        this.autoId = autoId;
-    }
-
-    public Long getAutoId()
-    {
-        return autoId;
-    }
-    public void setHouseId(Long houseId)
-    {
-        this.houseId = houseId;
-    }
-
-    public Long getHouseId()
-    {
-        return houseId;
-    }
-    public void setHouseName(String houseName)
-    {
-        this.houseName = houseName;
-    }
-
-    public String getHouseName()
-    {
-        return houseName;
-    }
-    public void setHouseCode(String houseCode)
-    {
-        this.houseCode = houseCode;
-    }
-
-    public String getHouseCode()
-    {
-        return houseCode;
-    }
-    public void setDeviceName(String deviceName)
-    {
-        this.deviceName = deviceName;
-    }
-
-    public String getDeviceName()
-    {
-        return deviceName;
-    }
-    public void setDeviceCode(String deviceCode)
-    {
-        this.deviceCode = deviceCode;
-    }
-
-    public String getDeviceCode()
-    {
-        return deviceCode;
-    }
-    public void setManufacturer(String manufacturer)
-    {
-        this.manufacturer = manufacturer;
-    }
-
-    public String getManufacturer()
-    {
-        return manufacturer;
-    }
-    public void setModel(String model)
-    {
-        this.model = model;
-    }
-
-    public String getModel()
-    {
-        return model;
-    }
-    public void setStatus(String status)
-    {
-        this.status = status;
-    }
-
-    public String getStatus()
-    {
-        return status;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("autoId", getAutoId())
-            .append("houseId", getHouseId())
-            .append("houseName", getHouseName())
-            .append("houseCode", getHouseCode())
-            .append("deviceName", getDeviceName())
-            .append("deviceCode", getDeviceCode())
-            .append("manufacturer", getManufacturer())
-            .append("model", getModel())
-            .append("status", getStatus())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
 }

+ 3 - 1
jjt-admin/src/main/java/com/jjt/biz/service/impl/DeviceChannelsServiceImpl.java

@@ -120,6 +120,8 @@ public class DeviceChannelsServiceImpl implements IDeviceChannelsService {
      */
     @Override
     public List<DeviceChannels> findByCode(String deviceCode) {
-        return null;
+        DeviceChannels deviceChannels = new DeviceChannels();
+        deviceChannels.setDeviceCode(deviceCode);
+        return selectDeviceChannelsList(deviceChannels);
     }
 }

+ 42 - 27
jjt-admin/src/main/resources/mapper/biz/FlowsRecordMapper.xml

@@ -1,38 +1,51 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jjt.biz.mapper.FlowsRecordMapper">
-    
+
     <resultMap type="FlowsRecord" id="FlowsRecordResult">
-        <result property="recordId"    column="RECORD_ID"    />
-        <result property="flowsName"    column="FLOWS_NAME"    />
-        <result property="house"    column="HOUSE"    />
-        <result property="area"    column="AREA"    />
-        <result property="status"    column="STATUS"    />
-        <result property="journeyUrl"    column="JOURNEY_URL"    />
-        <result property="createBy"    column="CREATE_BY"    />
-        <result property="createTime"    column="CREATE_TIME"    />
-        <result property="updateBy"    column="UPDATE_BY"    />
-        <result property="updateTime"    column="UPDATE_TIME"    />
-        <result property="remark"    column="REMARK"    />
+        <result property="recordId" column="RECORD_ID"/>
+        <result property="flowsName" column="FLOWS_NAME"/>
+        <result property="house" column="HOUSE"/>
+        <result property="area" column="AREA"/>
+        <result property="status" column="STATUS"/>
+        <result property="journeyUrl" column="JOURNEY_URL"/>
+        <result property="createBy" column="CREATE_BY"/>
+        <result property="createTime" column="CREATE_TIME"/>
+        <result property="updateBy" column="UPDATE_BY"/>
+        <result property="updateTime" column="UPDATE_TIME"/>
+        <result property="remark" column="REMARK"/>
     </resultMap>
 
     <sql id="selectFlowsRecordVo">
-        select RECORD_ID, FLOWS_NAME, HOUSE, AREA, STATUS, JOURNEY_URL, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK from flows_record
+        select RECORD_ID,
+               FLOWS_NAME,
+               HOUSE,
+               AREA,
+               STATUS,
+               JOURNEY_URL,
+               CREATE_BY,
+               CREATE_TIME,
+               UPDATE_BY,
+               UPDATE_TIME,
+               REMARK
+        from flows_record
     </sql>
 
     <select id="selectFlowsRecordList" parameterType="FlowsRecord" resultMap="FlowsRecordResult">
         <include refid="selectFlowsRecordVo"/>
-        <where>  
-            <if test="flowsName != null  and flowsName != ''"> and FLOWS_NAME like concat('%', #{flowsName}, '%')</if>
-            <if test="house != null  and house != ''"> and HOUSE = #{house}</if>
-            <if test="area != null  and area != ''"> and AREA = #{area}</if>
-            <if test="status != null  and status != ''"> and STATUS = #{status}</if>
-            <if test="journeyUrl != null  and journeyUrl != ''"> and JOURNEY_URL = #{journeyUrl}</if>
+        <where>
+            <if test="flowsName != null  and flowsName != ''">and FLOWS_NAME like concat('%', #{flowsName}, '%')</if>
+            <if test="house != null  and house != ''">and HOUSE like concat('%', #{house}, '%')</if>
+            <if test="area != null  and area != ''">and AREA = #{area}</if>
+            <if test="status != null  and status != ''">and STATUS = #{status}</if>
+            <if test="journeyUrl != null  and journeyUrl != ''">and JOURNEY_URL = #{journeyUrl}</if>
+            <if test="updateBy != null  and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
         </where>
+        order by create_time desc
     </select>
-    
+
     <select id="selectFlowsRecordByRecordId" parameterType="Long" resultMap="FlowsRecordResult">
         <include refid="selectFlowsRecordVo"/>
         where RECORD_ID = #{recordId}
@@ -52,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">UPDATE_BY,</if>
             <if test="updateTime != null">UPDATE_TIME,</if>
             <if test="remark != null">REMARK,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="recordId != null">#{recordId},</if>
             <if test="flowsName != null">#{flowsName},</if>
@@ -65,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateFlowsRecord" parameterType="FlowsRecord">
@@ -86,13 +99,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteFlowsRecordByRecordId" parameterType="Long">
-        delete from flows_record where RECORD_ID = #{recordId}
+        delete
+        from flows_record
+        where RECORD_ID = #{recordId}
     </delete>
 
     <delete id="deleteFlowsRecordByRecordIds" parameterType="String">
-        delete from flows_record where RECORD_ID in 
+        delete from flows_record where RECORD_ID in
         <foreach item="recordId" collection="array" open="(" separator="," close=")">
             #{recordId}
         </foreach>
     </delete>
-</mapper>
+</mapper>