浏览代码

设备保障监控

shudonghui 1 年之前
父节点
当前提交
64cdc8998c

+ 0 - 1
sop-api/src/main/java/com/qmth/sop/server/api/CrmAnalyseController.java

@@ -2,7 +2,6 @@ package com.qmth.sop.server.api;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.CrmAnalyseResult;
 import com.qmth.sop.business.bean.result.TBCrmResult;

+ 78 - 0
sop-api/src/main/java/com/qmth/sop/server/api/DeviceMonitorController.java

@@ -0,0 +1,78 @@
+package com.qmth.sop.server.api;
+
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.service.DeviceMonitorService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 设备保障监控 控制器
+ *
+ * @author: shudonghui
+ * @date: 2023-08-14 15:55:18
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
+ */
+@Api(tags = "设备保障监控 Controller")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DEVICE + "/monitor")
+public class DeviceMonitorController {
+
+
+    @Resource
+    DeviceMonitorService deviceMonitorService;
+
+    
+    @ApiOperation(value = "库存监控统计接口")
+    @RequestMapping(value = "/count", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "库存监控统计", response = Map.class)})
+    public Result count(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId,
+                        @ApiParam(value = "型号", required = false) @RequestParam(required = false) String model
+    ) {
+        Map<String, Object> map = deviceMonitorService.count(supplierId, model);
+
+        return ResultUtil.ok(map);
+    }
+
+    //按型号统计状态明细
+    
+    @ApiOperation(value = "按型号统计状态明细")
+    @RequestMapping(value = "/countByModel", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "按型号统计状态明细", response = List.class)})
+    public Result countByModel(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId) {
+        List<Map<String, Object>> list = deviceMonitorService.countByModel(supplierId);
+
+        return ResultUtil.ok(list);
+    }
+
+    //按服务单元统计设备状态
+    
+    @ApiOperation(value = "按服务单元统计设备状态")
+    @RequestMapping(value = "/countByServiceUnit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态", response = Map.class)})
+    public Result countByServiceUnit() {
+        Map<String, Object> map = deviceMonitorService.countByServiceUnit();
+        return ResultUtil.ok(map);
+    }
+    //按服务单元统计设备状态明细
+    
+    @ApiOperation(value = "按服务单元统计设备状态明细")
+    @RequestMapping(value = "/countByServiceUnitDetail", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态明细", response = List.class)})
+    public Result countByServiceUnitDetail() {
+        List<Map<String, Object>> list = deviceMonitorService.countByServiceUnitDetail();
+        return ResultUtil.ok(list);
+    }
+
+}

+ 27 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/DeviceMonitorMapper.java

@@ -0,0 +1,27 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.sop.business.entity.SysDevice;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author dhshu
+ *
+ */
+public interface DeviceMonitorMapper extends BaseMapper<SysDevice> {
+
+
+    Map<String, Object> count(@Param("supplierId") Long supplierId,@Param("model") String model);
+
+    List<Map<String, Object>> countByModel(@Param("supplierId") Long supplierId);
+
+    Map<String, Object> countByServiceUnit();
+
+    List<Map<String, Object>> countByServiceUnitDetail();
+}

+ 17 - 0
sop-business/src/main/java/com/qmth/sop/business/service/DeviceMonitorService.java

@@ -0,0 +1,17 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.SysDevice;
+
+import java.util.List;
+import java.util.Map;
+
+public interface DeviceMonitorService extends IService<SysDevice> {
+    Map<String, Object> count(Long supplierId, String model);
+
+    List<Map<String, Object>> countByModel(Long supplierId);
+
+    Map<String, Object> countByServiceUnit();
+
+    List<Map<String, Object>> countByServiceUnitDetail();
+}

+ 40 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/DeviceMonitorServiceImpl.java

@@ -0,0 +1,40 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.entity.SysDevice;
+import com.qmth.sop.business.mapper.DeviceMonitorMapper;
+import com.qmth.sop.business.service.DeviceMonitorService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author dhshu
+ * @date:
+ */
+@Service
+public class DeviceMonitorServiceImpl extends ServiceImpl<DeviceMonitorMapper, SysDevice> implements DeviceMonitorService {
+
+
+    @Override
+    public Map<String, Object> count(Long supplierId, String model) {
+        return this.baseMapper.count(supplierId, model);
+    }
+
+    @Override
+    public List<Map<String, Object>> countByModel(Long supplierId) {
+        return this.baseMapper.countByModel(supplierId);
+    }
+
+    @Override
+    public Map<String, Object> countByServiceUnit() {
+        return this.baseMapper.countByServiceUnit();
+    }
+
+    @Override
+    public List<Map<String, Object>> countByServiceUnitDetail() {
+        return this.baseMapper.countByServiceUnitDetail();
+    }
+}

+ 65 - 0
sop-business/src/main/resources/mapper/DeviceMonitorMapper.xml

@@ -0,0 +1,65 @@
+<?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">
+<mapper namespace="com.qmth.sop.business.mapper.DeviceMonitorMapper">
+    <select id="count" resultType="java.util.Map">
+        SELECT count(d.id) TOTAL,
+        sum(case when d.bound='OUT' then 1 else 0 end) ISOUT,
+        sum(case when d.bound='IN' and d.`status`!='BREAK_DOWN' then 1 else 0 end) ISIN,
+        sum(case when d.`status`='BREAK_DOWN' then 1 else 0 end) BREAK_DOWN
+        from sys_device d
+        <where>
+            <if test="supplierId != null and supplierId != ''">
+                and d.supplier_id = #{supplierId}
+            </if>
+            <if test="model != null and model != ''">
+                and d.model = #{model}
+            </if>
+        </where>
+    </select>
+
+
+    <select id="countByModel" resultType="java.util.Map">
+        SELECT
+        d.model MODEL,
+        count( d.id ) TOTAL,
+        sum( CASE WHEN d.bound = 'OUT' THEN 1 ELSE 0 END ) ISOUT,
+        sum( CASE WHEN d.bound='IN' and d.`status`!='BREAK_DOWN' THEN 1 ELSE 0 END ) ISIN,
+        sum( CASE WHEN d.`status` = 'BREAK_DOWN' THEN 1 ELSE 0 END ) BREAK_DOWN
+        FROM
+        sys_device d
+        <where>
+            <if test="supplierId != null and supplierId != ''">
+                and d.supplier_id = #{supplierId}
+            </if>
+        </where>
+        group by d.model
+    </select>
+    <select id="countByServiceUnit" resultType="java.util.Map">
+        SELECT
+        sum( CASE WHEN s.`status` = 'PUBLISH' AND l.id IS NOT NULL THEN l.devices ELSE 0 END ) DEVICES,
+        sum( CASE WHEN d.bound = 'OUT' THEN 1 ELSE 0 END ) OUTS
+        FROM
+        t_b_service s
+        LEFT JOIN t_b_crm c ON c.service_id = s.id
+        LEFT JOIN sys_custom cu ON cu.id = c.custom_id
+        LEFT JOIN sys_level l ON l.id = cu.level_id
+
+        left join t_b_device_in_out io on io.service_id=s.id
+        left join sys_device d on d.device_code=io.device_no
+
+    </select>
+    <select id="countByServiceUnitDetail" resultType="java.util.Map">
+        SELECT
+        s.`name` NAME,sum( l.devices ) devices ,sum(case when d.bound='OUT' then 1 else 0 end ) OUTS
+        FROM
+        t_b_service s
+        LEFT JOIN t_b_crm c ON c.service_id = s.id
+        LEFT JOIN sys_custom cu ON cu.id = c.custom_id
+        LEFT JOIN sys_level l ON l.id = cu.level_id
+
+        left join t_b_device_in_out io on io.service_id=s.id
+        left join sys_device d on d.device_code=io.device_no
+
+        GROUP BY s.`name`
+    </select>
+</mapper>