厂区看板接口开发
This commit is contained in:
parent
a6851ff16a
commit
1484d20a73
@ -0,0 +1,33 @@
|
|||||||
|
package com.inspur.web.controller.bigscreen;
|
||||||
|
|
||||||
|
import com.inspur.bigscreen.service.ICompanyDashboardService;
|
||||||
|
import com.inspur.common.core.domain.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司级控制层
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bigscreen/company")
|
||||||
|
public class CompanyDashboardController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICompanyDashboardService factoryDashboardService;
|
||||||
|
|
||||||
|
@GetMapping("/countEquipNumByCompany/{deptId}")
|
||||||
|
public AjaxResult countEquipNumByCompany(@PathVariable Long deptId) {
|
||||||
|
return AjaxResult.success(factoryDashboardService.countEquipNumByStatus(deptId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/countEquipNumByDiffCompany/{deptId}")
|
||||||
|
public AjaxResult countEquipNumByDiffCompany(@PathVariable Long deptId) {
|
||||||
|
return AjaxResult.success(factoryDashboardService.countEquipNumByCompanyId(deptId));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.inspur.bigscreen.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
public class EquipInfoStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行
|
||||||
|
*/
|
||||||
|
public static final Integer RUNNING = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维修保养
|
||||||
|
*/
|
||||||
|
public static final Integer MAINTENANCE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停机
|
||||||
|
*/
|
||||||
|
public static final Integer STOP = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报废
|
||||||
|
*/
|
||||||
|
public static final Integer SCRAP = 3;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.inspur.bigscreen.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司级产线
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CompanyDashboardDTO {
|
||||||
|
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
private Integer data;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
private List<String> x;
|
||||||
|
|
||||||
|
private List<Object> y;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.inspur.bigscreen.mapper;
|
||||||
|
|
||||||
|
import com.inspur.bigscreen.dto.CompanyDashboardDTO;
|
||||||
|
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
public interface CompanyDashboardMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询公司的各个状态设备数量
|
||||||
|
* @param deptId
|
||||||
|
*/
|
||||||
|
public CompanyDashboardDTO countDiffStatusCompanyEquipNumByDeptId(@Param("deptId")Long deptId,
|
||||||
|
@Param("status")Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据厂区部门id查询设备总数
|
||||||
|
*/
|
||||||
|
public CompanyDashboardDTO countEquipNumByCompany(@Param("deptId")Long deptId);
|
||||||
|
|
||||||
|
}
|
@ -23,7 +23,8 @@ public interface FactoryDashboardMapper {
|
|||||||
/**
|
/**
|
||||||
* 根据厂区部门id查询各个产线不同状态设备数
|
* 根据厂区部门id查询各个产线不同状态设备数
|
||||||
*/
|
*/
|
||||||
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId);
|
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(@Param("deptId")Long deptId,
|
||||||
|
@Param("status")Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据厂区部门id查询各个产线传感器数量
|
* 根据厂区部门id查询各个产线传感器数量
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.inspur.bigscreen.service;
|
||||||
|
|
||||||
|
import com.inspur.bigscreen.dto.CompanyDashboardDTO;
|
||||||
|
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司级业务层接口
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
public interface ICompanyDashboardService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计不同状态公司设备数
|
||||||
|
*/
|
||||||
|
public List<CompanyDashboardDTO> countEquipNumByStatus(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司id统计公司设备数
|
||||||
|
*/
|
||||||
|
public List<CompanyDashboardDTO> countEquipNumByCompanyId(Long deptId);
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.inspur.bigscreen.service.impl;
|
||||||
|
|
||||||
|
import com.inspur.bigscreen.constant.EquipInfoStatus;
|
||||||
|
import com.inspur.bigscreen.dto.CompanyDashboardDTO;
|
||||||
|
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
|
||||||
|
import com.inspur.bigscreen.mapper.CompanyDashboardMapper;
|
||||||
|
import com.inspur.bigscreen.service.ICompanyDashboardService;
|
||||||
|
import com.inspur.bigscreen.service.IFactoryDashboardService;
|
||||||
|
import com.inspur.common.core.domain.entity.SysDept;
|
||||||
|
import com.inspur.system.mapper.SysDeptMapper;
|
||||||
|
import com.inspur.system.service.ISysDeptService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司级业务层
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/7/15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CompanyDashboardService implements ICompanyDashboardService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CompanyDashboardMapper companyDashboardMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDeptMapper sysDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计不同状态公司设备数
|
||||||
|
*/
|
||||||
|
public List<CompanyDashboardDTO> countEquipNumByStatus(Long deptId){
|
||||||
|
List<CompanyDashboardDTO> resultList = new ArrayList<>();
|
||||||
|
CompanyDashboardDTO runData = companyDashboardMapper.countDiffStatusCompanyEquipNumByDeptId(deptId, EquipInfoStatus.RUNNING);
|
||||||
|
CompanyDashboardDTO stopData = companyDashboardMapper.countDiffStatusCompanyEquipNumByDeptId(deptId, EquipInfoStatus.STOP);
|
||||||
|
CompanyDashboardDTO maintainData = companyDashboardMapper.countDiffStatusCompanyEquipNumByDeptId(deptId, EquipInfoStatus.MAINTENANCE);
|
||||||
|
resultList.add(runData);
|
||||||
|
resultList.add(stopData);
|
||||||
|
resultList.add(maintainData);
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司id统计公司设备数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CompanyDashboardDTO> countEquipNumByCompanyId(Long deptId){
|
||||||
|
//查询给定公司id的厂区id
|
||||||
|
List<SysDept> childDeptList = sysDeptMapper.selectChildrenDeptById(deptId);
|
||||||
|
List<SysDept> factoryDeptList = childDeptList.stream().filter(dept -> dept.getAncestors().split(",").length == 3 ).collect(Collectors.toList());
|
||||||
|
List<CompanyDashboardDTO> resultList = new ArrayList<>();
|
||||||
|
factoryDeptList.forEach(factoryDept -> {
|
||||||
|
CompanyDashboardDTO companyDashboardDTO = companyDashboardMapper.countEquipNumByCompany(factoryDept.getDeptId());
|
||||||
|
resultList.add(companyDashboardDTO);
|
||||||
|
});
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.inspur.bigscreen.service.impl;
|
package com.inspur.bigscreen.service.impl;
|
||||||
|
|
||||||
|
import com.inspur.bigscreen.constant.EquipInfoStatus;
|
||||||
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
|
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
|
||||||
import com.inspur.bigscreen.mapper.FactoryDashboardMapper;
|
import com.inspur.bigscreen.mapper.FactoryDashboardMapper;
|
||||||
import com.inspur.bigscreen.service.IFactoryDashboardService;
|
import com.inspur.bigscreen.service.IFactoryDashboardService;
|
||||||
@ -31,6 +32,7 @@ public class FactoryDashboardService implements IFactoryDashboardService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IIpcAlarmRecordService ipcAlarmRecordService;
|
private IIpcAlarmRecordService ipcAlarmRecordService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param deptId 厂区的部门id
|
* @param deptId 厂区的部门id
|
||||||
*根据厂区id查询厂区下所有产线设备数量
|
*根据厂区id查询厂区下所有产线设备数量
|
||||||
@ -55,7 +57,14 @@ public class FactoryDashboardService implements IFactoryDashboardService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId){
|
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId){
|
||||||
return factoryDashboardMapper.countEquipNumByStatusandProductionLine(deptId);
|
List<FactoryDashboardDTO> runningDataList = factoryDashboardMapper.countEquipNumByStatusandProductionLine(deptId,EquipInfoStatus.RUNNING);
|
||||||
|
List<FactoryDashboardDTO> matenanceDataList = factoryDashboardMapper.countEquipNumByStatusandProductionLine(deptId,EquipInfoStatus.MAINTENANCE);
|
||||||
|
List<FactoryDashboardDTO> stopDataList = factoryDashboardMapper.countEquipNumByStatusandProductionLine(deptId,EquipInfoStatus.STOP);
|
||||||
|
List<FactoryDashboardDTO> resultList = new ArrayList<>();
|
||||||
|
resultList.addAll(runningDataList);
|
||||||
|
resultList.addAll(matenanceDataList);
|
||||||
|
resultList.addAll(stopDataList);
|
||||||
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
<?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.inspur.bigscreen.mapper.CompanyDashboardMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.inspur.bigscreen.dto.CompanyDashboardDTO" id="companyData">
|
||||||
|
<result property="deptId" column="dept_id"/>
|
||||||
|
<result property="deptName" column="dept_name"/>
|
||||||
|
<result property="data" column="data"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="time" column="time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectWeeklyDate">
|
||||||
|
select curdate() as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 1 day) as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 2 day) as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 3 day) as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 4 day) as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 5 day) as click_date
|
||||||
|
union all
|
||||||
|
select date_sub(curdate(), interval 6 day) as click_date
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!--查询公司设备数量-->
|
||||||
|
<select id="countDiffStatusCompanyEquipNumByDeptId" resultMap="companyData">
|
||||||
|
select
|
||||||
|
#{status} as status,
|
||||||
|
COUNT(1) as data
|
||||||
|
from
|
||||||
|
ipc_equip_info
|
||||||
|
where
|
||||||
|
dept_id in
|
||||||
|
(select dept_id from sys_dept where FIND_IN_SET(#{deptId}, ancestors))
|
||||||
|
and status = #{status}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据公司id查询设备总数
|
||||||
|
public CompanyDashboardDTO countEquipNumByCompany-->
|
||||||
|
<select id="countEquipNumByCompany" parameterType="Long" resultMap="companyData">
|
||||||
|
select
|
||||||
|
#{deptId} as dept_id,
|
||||||
|
(select dept_name from sys_dept where dept_id = #{deptId}) as dept_name,
|
||||||
|
COUNT(1) as data
|
||||||
|
from
|
||||||
|
ipc_equip_info
|
||||||
|
where
|
||||||
|
dept_id in
|
||||||
|
(select dept_id from sys_dept where FIND_IN_SET(#{deptId}, ancestors) or dept_id = #{deptId})
|
||||||
|
and status in (0,1,2)-- 0:离线 1:在线 2:故障
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -33,16 +33,31 @@
|
|||||||
select dept_id,count(1) as data from ipc_equip_info
|
select dept_id,count(1) as data from ipc_equip_info
|
||||||
where dept_id in
|
where dept_id in
|
||||||
(select dept_id from sys_dept where parent_id = #{deptId})
|
(select dept_id from sys_dept where parent_id = #{deptId})
|
||||||
|
and status != 3
|
||||||
GROUP BY dept_id;
|
GROUP BY dept_id;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--根据厂区部门id查询各个产线不同状态设备数-->
|
<!--根据厂区部门id查询各个产线不同状态设备数-->
|
||||||
<select id="countEquipNumByStatusandProductionLine" parameterType="Long" resultMap="factoryData">
|
<select id="countEquipNumByStatusandProductionLine" resultMap="factoryData">
|
||||||
select a.dept_id,b.dept_name,a.status,count(1) as data
|
SELECT
|
||||||
from `ipc_equip_info` a
|
d.dept_id,
|
||||||
left join sys_dept b on a.dept_id = b. dept_id
|
d.dept_name,
|
||||||
where a.dept_id in (select dept_id from sys_dept where parent_id = #{deptId})
|
COALESCE(ei.data, 0) AS data,
|
||||||
GROUP BY a.dept_id,a.status;
|
#{status} AS status
|
||||||
|
FROM
|
||||||
|
(SELECT dept_id,dept_name FROM sys_dept WHERE FIND_IN_SET(#{deptId}, ancestors)) d -- 生成所有可能的dept_id和dept_name
|
||||||
|
LEFT JOIN
|
||||||
|
(SELECT
|
||||||
|
a.dept_id,
|
||||||
|
COUNT(1) AS data
|
||||||
|
FROM
|
||||||
|
ipc_equip_info a
|
||||||
|
WHERE
|
||||||
|
a.status = #{status}
|
||||||
|
GROUP BY
|
||||||
|
a.dept_id) ei -- 子查询来计数满足条件的记录
|
||||||
|
ON
|
||||||
|
d.dept_id = ei.dept_id;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--根据厂区部门id查询各个产线传感器数量
|
<!--根据厂区部门id查询各个产线传感器数量
|
||||||
|
@ -31,3 +31,36 @@ export function getWeeklyAlarmNumByProductionLine(deptId) {
|
|||||||
method: "get",
|
method: "get",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//按照工厂id查询不同产线一周的设备正常数量变化
|
||||||
|
export function getWeeklyEquipRunningNum(deptId) {
|
||||||
|
return request({
|
||||||
|
url: "/bigscreen/factory/countWeeklyEquipRunningNumByLineDeptId/" + deptId,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据厂区id查询不同产线半年的维修记录数
|
||||||
|
export function getHYMaintenanceRecordNumByProductionLine(deptId) {
|
||||||
|
return request({
|
||||||
|
url:
|
||||||
|
"/bigscreen/factory/countMaintenanceRecordNumByProductionLine/" + deptId,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据厂区id查询不同产线半年的保养记录数
|
||||||
|
export function getHYUpkeepRecordNumByProductionLine(deptId) {
|
||||||
|
return request({
|
||||||
|
url: "/bigscreen/factory/countUpkeepRecordNumByProductionLine/" + deptId,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据厂区id查询最新的报警信息
|
||||||
|
export function getLatestAlarmRecord(deptId) {
|
||||||
|
return request({
|
||||||
|
url: "/bigscreen/factory/listLatestAlarmRecord/" + deptId,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -456,6 +456,10 @@ import {
|
|||||||
getHYUpkeepRecordNumByProductionLine,
|
getHYUpkeepRecordNumByProductionLine,
|
||||||
getLatestAlarmRecord,
|
getLatestAlarmRecord,
|
||||||
} from "@/api/bigscreen/factory";
|
} from "@/api/bigscreen/factory";
|
||||||
|
import {
|
||||||
|
getEquipNumByCompany,
|
||||||
|
getEquipNumByDiffCompany,
|
||||||
|
} from "@/api/bigscreen/company";
|
||||||
export default {
|
export default {
|
||||||
name: "Category",
|
name: "Category",
|
||||||
components: {
|
components: {
|
||||||
@ -583,10 +587,7 @@ export default {
|
|||||||
this.getList();
|
this.getList();
|
||||||
this.getDeptTree();
|
this.getDeptTree();
|
||||||
//测试
|
//测试
|
||||||
// getEquipNumByProductionLine(103);
|
getEquipNumByDiffCompany(101).then((response) => {
|
||||||
// getEquipNumByStatusAndProductionLine(103);
|
|
||||||
// getSensorNumByProductionLine(103);
|
|
||||||
getLatestAlarmRecord(103).then((response) => {
|
|
||||||
console.log("data:", response.data);
|
console.log("data:", response.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user