产线使用大屏接口功能开发

This commit is contained in:
zhangjunwen 2024-07-11 17:33:05 +08:00
parent a558086d4d
commit 847a1bae5c
12 changed files with 726 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package com.inspur.web.controller.bigscreen;
import com.inspur.bigscreen.service.IFactoryDashboardService;
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/11
*/
@RestController
@RequestMapping("/bigscreen/factory")
public class FactoryDashboardController {
@Autowired
private IFactoryDashboardService factoryDashboardService;
@GetMapping("/countEquipNumByProductionLine/{deptId}")
public AjaxResult countEquipNumByProductionLine(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countEquipNumByProductionLine(deptId));
}
@GetMapping("/countEquipNumByStatusAndProductionLine/{deptId}")
public AjaxResult countEquipNumByStatusandProductionLine(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countEquipNumByStatusandProductionLine(deptId));
}
@GetMapping("/countSensorNumByProductionLine/{deptId}")
public AjaxResult countSensorNumByProductionLine(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countSensorNumByProductionLine(deptId));
}
@GetMapping("/countAlarmNumByProductionLine/{deptId}")
public AjaxResult countWeeklyAlarmNumByLineDeptId(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countAlarmNumByProductionLine(deptId));
}
}

View File

@ -0,0 +1,97 @@
package com.inspur.bigscreen.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspur.common.annotation.Excel;
import com.inspur.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 每日设备状态统计对象 ipc_daily_equip_num_by_status
*
* @author inspur
* @date 2024-07-11
*/
public class IpcDailyEquipNumByStatus extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 设备id */
@Excel(name = "设备id")
private String equipId;
/** 设备状态 */
@Excel(name = "设备状态")
private Integer status;
/** 设备所属部门id */
@Excel(name = "设备所属部门id")
private Long deptId;
/** 统计时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "统计时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setEquipId(String equipId)
{
this.equipId = equipId;
}
public String getEquipId()
{
return equipId;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setCreateDate(Date createDate)
{
this.createDate = createDate;
}
public Date getCreateDate()
{
return createDate;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("equipId", getEquipId())
.append("status", getStatus())
.append("deptId", getDeptId())
.append("createDate", getCreateDate())
.toString();
}
}

View File

@ -0,0 +1,27 @@
package com.inspur.bigscreen.dto;
import lombok.Data;
import java.util.List;
/**
* @Author zhangjunwen
* @create 2024/7/11
*/
@Data
public class FactoryDashboardDTO {
private Long deptId;
private String deptName;
private Integer data;
private Integer status;
private String time;
private List<String> x;
private List<Object> y;
}

View File

@ -0,0 +1,39 @@
package com.inspur.bigscreen.mapper;
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
import org.apache.ibatis.annotations.MapKey;
import java.util.List;
import java.util.Map;
/**
* @Author zhangjunwen
* @create 2024/7/11
*/
public interface FactoryDashboardMapper {
/**
* 查询公司下各个产线设备数量
*/
public List<FactoryDashboardDTO> countEquipNumByProductionLine(Long deptId);
/**
* 根据厂区部门id查询各个产线不同状态设备数
*/
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId);
/**
* 根据厂区部门id查询各个产线传感器数量
*/
public List<FactoryDashboardDTO> countSensorNumByProductionLine(Long deptId);
/**
* 根据产线部门id查询一周内各个产线报警数量
*/
public List<FactoryDashboardDTO> countWeeklyAlarmNumByLineDeptId(Long deptId);
/**
* 近一周产线各设备正常运行数量
*/
public List<FactoryDashboardDTO> countWeeklyEquipRunningNumByLineDeptId(Long deptId);
}

View File

@ -0,0 +1,61 @@
package com.inspur.bigscreen.mapper;
import java.util.List;
import com.inspur.bigscreen.domain.IpcDailyEquipNumByStatus;
/**
* 每日设备状态统计Mapper接口
*
* @author inspur
* @date 2024-07-11
*/
public interface IpcDailyEquipNumByStatusMapper
{
/**
* 查询每日设备状态统计
*
* @param id 每日设备状态统计主键
* @return 每日设备状态统计
*/
public IpcDailyEquipNumByStatus selectIpcDailyEquipNumByStatusById(Long id);
/**
* 查询每日设备状态统计列表
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 每日设备状态统计集合
*/
public List<IpcDailyEquipNumByStatus> selectIpcDailyEquipNumByStatusList(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 新增每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
public int insertIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 修改每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
public int updateIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 删除每日设备状态统计
*
* @param id 每日设备状态统计主键
* @return 结果
*/
public int deleteIpcDailyEquipNumByStatusById(Long id);
/**
* 批量删除每日设备状态统计
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteIpcDailyEquipNumByStatusByIds(Long[] ids);
}

View File

@ -0,0 +1,34 @@
package com.inspur.bigscreen.service;
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
import java.util.List;
import java.util.Map;
/**
* @Author zhangjunwen
* @create 2024/7/11
*/
public interface IFactoryDashboardService {
/**
*根据厂区id查询厂区下所有产线设备数量
*/
public List<FactoryDashboardDTO> countEquipNumByProductionLine(Long deptId);
/**
* 根据厂区部门id查询各个产线不同状态设备数
*/
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId);
/**
* 根据厂区部门id查询各个产线传感器数量
*/
public List<FactoryDashboardDTO> countSensorNumByProductionLine(Long deptId);
/**
* 根据厂区部门id查询各个产线报警数量
*/
public List<FactoryDashboardDTO> countAlarmNumByProductionLine(Long deptId);
}

View File

@ -0,0 +1,62 @@
package com.inspur.bigscreen.service;
import java.util.List;
import com.inspur.bigscreen.domain.IpcDailyEquipNumByStatus;
/**
* 每日设备状态统计Service接口
*
* @author inspur
* @date 2024-07-11
*/
public interface IIpcDailyEquipNumByStatusService
{
/**
* 查询每日设备状态统计
*
* @param id 每日设备状态统计主键
* @return 每日设备状态统计
*/
public IpcDailyEquipNumByStatus selectIpcDailyEquipNumByStatusById(Long id);
/**
* 查询每日设备状态统计列表
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 每日设备状态统计集合
*/
public List<IpcDailyEquipNumByStatus> selectIpcDailyEquipNumByStatusList(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 新增每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
public int insertIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 修改每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
public int updateIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus);
/**
* 批量删除每日设备状态统计
*
* @param ids 需要删除的每日设备状态统计主键集合
* @return 结果
*/
public int deleteIpcDailyEquipNumByStatusByIds(Long[] ids);
/**
* 删除每日设备状态统计信息
*
* @param id 每日设备状态统计主键
* @return 结果
*/
public int deleteIpcDailyEquipNumByStatusById(Long id);
}

View File

@ -0,0 +1,85 @@
package com.inspur.bigscreen.service.impl;
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
import com.inspur.bigscreen.mapper.FactoryDashboardMapper;
import com.inspur.bigscreen.service.IFactoryDashboardService;
import com.inspur.common.core.domain.entity.SysDept;
import com.inspur.system.mapper.SysDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author zhangjunwen
* @create 2024/7/11
*/
@Service
public class FactoryDashboardService implements IFactoryDashboardService {
@Autowired
private FactoryDashboardMapper factoryDashboardMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
/**
* @param deptId 厂区的部门id
*根据厂区id查询厂区下所有产线设备数量
*/
@Override
public List<FactoryDashboardDTO> countEquipNumByProductionLine(Long deptId){
List<FactoryDashboardDTO> resultList = new ArrayList<>();
List<FactoryDashboardDTO> factoryDashboardDTOList = factoryDashboardMapper.countEquipNumByProductionLine(deptId);
for (FactoryDashboardDTO factoryDashboardDTO : factoryDashboardDTOList) {
SysDept deptInfo = sysDeptMapper.selectDeptById(factoryDashboardDTO.getDeptId());
factoryDashboardDTO.setDeptName(deptInfo.getDeptName());
resultList.add(factoryDashboardDTO);
}
return resultList;
}
/**
* @param deptId 厂区的部门id
* 根据厂区部门id查询各个产线不同状态设备数
*/
@Override
public List<FactoryDashboardDTO> countEquipNumByStatusandProductionLine(Long deptId){
return factoryDashboardMapper.countEquipNumByStatusandProductionLine(deptId);
}
/**
* @param deptId 厂区的部门id
* 根据厂区部门id查询各个产线传感器数量
*/
@Override
public List<FactoryDashboardDTO> countSensorNumByProductionLine(Long deptId){
return factoryDashboardMapper.countSensorNumByProductionLine(deptId);
}
/**
* 根据厂区部门id查询各个产线报警数量
*/
@Override
public List<FactoryDashboardDTO> countAlarmNumByProductionLine(Long deptId){
List<FactoryDashboardDTO> resultList = new ArrayList<>();
List<SysDept> childDeptList = sysDeptMapper.selectChildrenDeptById(deptId);
for (SysDept sysDept : childDeptList) {
FactoryDashboardDTO data = new FactoryDashboardDTO();
data.setDeptName(sysDept.getDeptName());
List<FactoryDashboardDTO> factoryDashboardDTOList = factoryDashboardMapper.countWeeklyAlarmNumByLineDeptId(sysDept.getDeptId());
List<String> timeList = factoryDashboardDTOList.stream().map(FactoryDashboardDTO::getTime).collect(Collectors.toList());
List<Object> dataList = factoryDashboardDTOList.stream().map(FactoryDashboardDTO::getData).collect(Collectors.toList());
data.setX(timeList);
data.setY(dataList);
resultList.add(data);
}
return resultList;
}
}

View File

@ -0,0 +1,94 @@
package com.inspur.bigscreen.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.inspur.bigscreen.mapper.IpcDailyEquipNumByStatusMapper;
import com.inspur.bigscreen.domain.IpcDailyEquipNumByStatus;
import com.inspur.bigscreen.service.IIpcDailyEquipNumByStatusService;
/**
* 每日设备状态统计Service业务层处理
*
* @author inspur
* @date 2024-07-11
*/
@Service
public class IpcDailyEquipNumByStatusServiceImpl implements IIpcDailyEquipNumByStatusService
{
@Autowired
private IpcDailyEquipNumByStatusMapper ipcDailyEquipNumByStatusMapper;
/**
* 查询每日设备状态统计
*
* @param id 每日设备状态统计主键
* @return 每日设备状态统计
*/
@Override
public IpcDailyEquipNumByStatus selectIpcDailyEquipNumByStatusById(Long id)
{
return ipcDailyEquipNumByStatusMapper.selectIpcDailyEquipNumByStatusById(id);
}
/**
* 查询每日设备状态统计列表
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 每日设备状态统计
*/
@Override
public List<IpcDailyEquipNumByStatus> selectIpcDailyEquipNumByStatusList(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus)
{
return ipcDailyEquipNumByStatusMapper.selectIpcDailyEquipNumByStatusList(ipcDailyEquipNumByStatus);
}
/**
* 新增每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
@Override
public int insertIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus)
{
return ipcDailyEquipNumByStatusMapper.insertIpcDailyEquipNumByStatus(ipcDailyEquipNumByStatus);
}
/**
* 修改每日设备状态统计
*
* @param ipcDailyEquipNumByStatus 每日设备状态统计
* @return 结果
*/
@Override
public int updateIpcDailyEquipNumByStatus(IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus)
{
return ipcDailyEquipNumByStatusMapper.updateIpcDailyEquipNumByStatus(ipcDailyEquipNumByStatus);
}
/**
* 批量删除每日设备状态统计
*
* @param ids 需要删除的每日设备状态统计主键
* @return 结果
*/
@Override
public int deleteIpcDailyEquipNumByStatusByIds(Long[] ids)
{
return ipcDailyEquipNumByStatusMapper.deleteIpcDailyEquipNumByStatusByIds(ids);
}
/**
* 删除每日设备状态统计信息
*
* @param id 每日设备状态统计主键
* @return 结果
*/
@Override
public int deleteIpcDailyEquipNumByStatusById(Long id)
{
return ipcDailyEquipNumByStatusMapper.deleteIpcDailyEquipNumByStatusById(id);
}
}

View File

@ -0,0 +1,81 @@
<?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.FactoryDashboardMapper">
<resultMap type="com.inspur.bigscreen.dto.FactoryDashboardDTO" id="factoryData">
<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="countEquipNumByProductionLine" parameterType="Long" resultMap="factoryData">
select dept_id,count(1) as data from ipc_equip_info
where dept_id in
(select dept_id from sys_dept where parent_id = #{deptId})
GROUP BY dept_id;
</select>
<!--根据厂区部门id查询各个产线不同状态设备数-->
<select id="countEquipNumByStatusandProductionLine" parameterType="Long" resultMap="factoryData">
select a.dept_id,b.dept_name,a.status,count(1) as data
from `ipc_equip_info` a
left join sys_dept b on a.dept_id = b. dept_id
where a.dept_id in (select dept_id from sys_dept where parent_id = #{deptId})
GROUP BY a.dept_id,a.status;
</select>
<!--根据厂区部门id查询各个产线传感器数量
public List<FactoryDashboardDTO> countSensorNumByProductionLine(Long deptId);-->
<select id="countSensorNumByProductionLine" parameterType="Long" resultMap="factoryData">
select a.dept_id,b.dept_name,count(1) as data
from ipc_sensor_info a
left join sys_dept b on a.dept_id = b. dept_id
where a.dept_id in (select dept_id from sys_dept where parent_id = #{deptId})
group by a.dept_id
</select>
<!--根据产线部门id查询一周内各个产线报警数量
public List<FactoryDashboardDTO> countAlarmNumByProductionLine(Long deptId);-->
<select id="countWeeklyAlarmNumByLineDeptId" parameterType="Long" resultMap="factoryData">
select a.click_date as time,ifnull(b.alarm_data,0) as data
from
(<include refid="selectWeeklyDate"/>)
a left join
(
select DATE(alarm_time) as alarm_time,count(1) as alarm_data
from ipc_alarm_record
where alarm_time >= CURDATE() - INTERVAL 7 DAY
and equip_id in (select id from ipc_equip_info where dept_id = #{deptId})
group by DATE(alarm_time)
) b
on a.click_date = b.alarm_time
</select>
<!--近一周产线各设备正常运行数量
public List<FactoryDashboardDTO> countWeeklyEquipRunningNumByLineDeptId(Long deptId);-->
<select id="countWeeklyEquipRunningNumByLineDeptId" parameterType="Long" resultMap="factoryData">
</select>
</mapper>

View File

@ -0,0 +1,71 @@
<?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.IpcDailyEquipNumByStatusMapper">
<resultMap type="IpcDailyEquipNumByStatus" id="IpcDailyEquipNumByStatusResult">
<result property="id" column="id" />
<result property="equipId" column="equip_id" />
<result property="status" column="status" />
<result property="deptId" column="dept_id" />
<result property="createDate" column="create_date" />
</resultMap>
<sql id="selectIpcDailyEquipNumByStatusVo">
select id, equip_id, status, dept_id, create_date from ipc_daily_equip_num_by_status
</sql>
<select id="selectIpcDailyEquipNumByStatusList" parameterType="IpcDailyEquipNumByStatus" resultMap="IpcDailyEquipNumByStatusResult">
<include refid="selectIpcDailyEquipNumByStatusVo"/>
<where>
<if test="equipId != null and equipId != ''"> and equip_id = #{equipId}</if>
<if test="status != null "> and status = #{status}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="createDate != null "> and create_date = #{createDate}</if>
</where>
</select>
<select id="selectIpcDailyEquipNumByStatusById" parameterType="Long" resultMap="IpcDailyEquipNumByStatusResult">
<include refid="selectIpcDailyEquipNumByStatusVo"/>
where id = #{id}
</select>
<insert id="insertIpcDailyEquipNumByStatus" parameterType="IpcDailyEquipNumByStatus" useGeneratedKeys="true" keyProperty="id">
insert into ipc_daily_equip_num_by_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="equipId != null">equip_id,</if>
<if test="status != null">status,</if>
<if test="deptId != null">dept_id,</if>
<if test="createDate != null">create_date,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="equipId != null">#{equipId},</if>
<if test="status != null">#{status},</if>
<if test="deptId != null">#{deptId},</if>
<if test="createDate != null">#{createDate},</if>
</trim>
</insert>
<update id="updateIpcDailyEquipNumByStatus" parameterType="IpcDailyEquipNumByStatus">
update ipc_daily_equip_num_by_status
<trim prefix="SET" suffixOverrides=",">
<if test="equipId != null">equip_id = #{equipId},</if>
<if test="status != null">status = #{status},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="createDate != null">create_date = #{createDate},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteIpcDailyEquipNumByStatusById" parameterType="Long">
delete from ipc_daily_equip_num_by_status where id = #{id}
</delete>
<delete id="deleteIpcDailyEquipNumByStatusByIds" parameterType="String">
delete from ipc_daily_equip_num_by_status where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,33 @@
import request from "@/utils/request";
// 按照工厂id查询设备数量
export function getEquipNumByProductionLine(deptId) {
return request({
url: "/bigscreen/factory/countEquipNumByProductionLine/" + deptId,
method: "get",
});
}
// 按照工厂id查询不同状态设备数量
export function getEquipNumByStatusAndProductionLine(deptId) {
return request({
url: "/bigscreen/factory/countEquipNumByStatusAndProductionLine/" + deptId,
method: "get",
});
}
// 按照工厂id查询不同状态传感器数量
export function getSensorNumByProductionLine(deptId) {
return request({
url: "/bigscreen/factory/countSensorNumByProductionLine/" + deptId,
method: "get",
});
}
// 按照工厂id查询不同产线一周的产线报警数
export function getWeeklyAlarmNumByProductionLine(deptId) {
return request({
url: "/bigscreen/factory/countAlarmNumByProductionLine/" + deptId,
method: "get",
});
}