Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhanghan11 2024-07-16 16:54:44 +08:00
commit b34ee99fee
37 changed files with 1432 additions and 35 deletions

View File

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

View File

@ -0,0 +1,62 @@
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));
}
@GetMapping("/countWeeklyEquipRunningNumByLineDeptId/{deptId}")
public AjaxResult countWeeklyEquipRunningNumByLineDeptId(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countWeeklyEquipRunningNumByLineDeptId(deptId));
}
@GetMapping("/countMaintenanceRecordNumByProductionLine/{deptId}")
public AjaxResult countMaintenanceRecordNumByProductionLine(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countMaintenanceRecordNumByProductionLine(deptId));
}
@GetMapping("/countUpkeepRecordNumByProductionLine/{deptId}")
public AjaxResult countUpkeepRecordNumByProductionLine(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.countUpkeepRecordNumByProductionLine(deptId));
}
@GetMapping("/listLatestAlarmRecord/{deptId}")
public AjaxResult listLatestAlarmRecord(@PathVariable Long deptId) {
return AjaxResult.success(factoryDashboardService.selectLatestIpcAlarmRecordByFactoryId(deptId));
}
}

View File

@ -34,8 +34,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
@Autowired
private SysPermissionService permissionService;
@Value("${user.deptId}")
private Long deptId;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
@ -56,9 +54,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
log.info("登录用户:{} 已被停用.", username);
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}
else if (deptId != null && !deptId.equals(user.getDeptId())){
throw new ServiceException("对不起,您的账号:" + username + " 不属于该工控机,无法登录");
}
passwordService.validate(user);

View File

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

View File

@ -0,0 +1,95 @@
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 */
private Integer nums;
/** 设备状态 */
@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 Integer getNums() {
return nums;
}
public void setNums(Integer nums) {
this.nums = nums;
}
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("status", getStatus())
.append("deptId", getDeptId())
.append("createDate", getCreateDate())
.toString();
}
}

View File

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

View File

@ -0,0 +1,28 @@
package com.inspur.bigscreen.dto;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
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,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);
}

View File

@ -0,0 +1,56 @@
package com.inspur.bigscreen.mapper;
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
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(@Param("deptId")Long deptId,
@Param("status")Integer status);
/**
* 根据厂区部门id查询各个产线传感器数量
*/
public List<FactoryDashboardDTO> countSensorNumByProductionLine(Long deptId);
/**
* 根据产线部门id查询一周内各个产线报警数量
*/
public List<FactoryDashboardDTO> countWeeklyAlarmNumByLineDeptId(Long deptId);
/**
* 近一周产线各设备正常运行数量
*/
public List<FactoryDashboardDTO> countWeeklyEquipRunningNumByLineDeptId(@Param("deptId") Long deptId,
@Param("status") Integer status);
/**
* 统计近半年的维修记录数量
*/
public FactoryDashboardDTO countMaintenanceRecordNumByProductionLine(@Param("date") Date date,
@Param("deptId")Long deptId);
/**
* 统计近半年的保养记录数量
*/
public FactoryDashboardDTO countUpkeepRecordNumByProductionLine(@Param("date") Date date,
@Param("deptId")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,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);
}

View File

@ -0,0 +1,55 @@
package com.inspur.bigscreen.service;
import com.inspur.bigscreen.dto.FactoryDashboardDTO;
import com.inspur.industrial.domain.IpcAlarmRecord;
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);
/**
* 近一周各个产线的运行情况
*/
public List<FactoryDashboardDTO> countWeeklyEquipRunningNumByLineDeptId(Long deptId);
/**
* 根据厂区id统计近半年各个产线的维修记录数
*/
public List<FactoryDashboardDTO> countMaintenanceRecordNumByProductionLine(Long deptId);
/**
* 根据厂区id统计近半年各个产线的保养记录数
*/
public List<FactoryDashboardDTO> countUpkeepRecordNumByProductionLine(Long deptId);
/**
* 根据厂区id查询最新的报警信息
*/
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId(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,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;
}
}

View File

@ -0,0 +1,218 @@
package com.inspur.bigscreen.service.impl;
import com.inspur.bigscreen.constant.EquipInfoStatus;
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.industrial.domain.IpcAlarmRecord;
import com.inspur.industrial.service.IIpcAlarmRecordService;
import com.inspur.system.mapper.SysDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
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;
@Autowired
private IIpcAlarmRecordService ipcAlarmRecordService;
/**
* @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){
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;
}
/**
* @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) {
List<FactoryDashboardDTO> factoryDashboardDTOList = factoryDashboardMapper.countWeeklyAlarmNumByLineDeptId(sysDept.getDeptId());
resultList.add(getResultData(sysDept,factoryDashboardDTOList));
}
return resultList;
}
/**
* 近一周各个产线的运行情况
* @param deptId 厂区id
*/
@Override
public List<FactoryDashboardDTO> countWeeklyEquipRunningNumByLineDeptId(Long deptId){
//根据厂区id查询厂区产线id
List<FactoryDashboardDTO> resultList = new ArrayList<>();
List<SysDept> childDeptList = sysDeptMapper.selectChildrenDeptById(deptId);
for (SysDept sysDept : childDeptList) {
List<FactoryDashboardDTO> factoryDashboardDTOList = factoryDashboardMapper.countWeeklyEquipRunningNumByLineDeptId(sysDept.getDeptId(),0);
resultList.add(getResultData(sysDept,factoryDashboardDTOList));
}
return resultList;
}
/**
* 根据厂区id统计近半年各个产线的维修记录数
*/
@Override
public List<FactoryDashboardDTO> countMaintenanceRecordNumByProductionLine(Long deptId){
List<FactoryDashboardDTO> resultList = new ArrayList<>();
List<SysDept> childDeptList = sysDeptMapper.selectChildrenDeptById(deptId);
for (SysDept sysDept : childDeptList) {
FactoryDashboardDTO data = getMatenanceDataByHalfYear(sysDept.getDeptId());
data.setDeptName(sysDept.getDeptName());
resultList.add(data);
}
return resultList;
}
/**
* 根据厂区id统计近半年各个产线的保养记录数
*/
@Override
public List<FactoryDashboardDTO> countUpkeepRecordNumByProductionLine(Long deptId){
List<FactoryDashboardDTO> resultList = new ArrayList<>();
List<SysDept> childDeptList = sysDeptMapper.selectChildrenDeptById(deptId);
for (SysDept sysDept : childDeptList) {
FactoryDashboardDTO data = getUpkeepDataByHalfYear(sysDept.getDeptId());
data.setDeptName(sysDept.getDeptName());
resultList.add(data);
}
return resultList;
}
/**
* 根据厂区id查询最新的报警信息
*/
@Override
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId(Long deptId){
return ipcAlarmRecordService.selectLatestIpcAlarmRecordByFactoryId(deptId);
}
private FactoryDashboardDTO getResultData(SysDept sysDept, List<FactoryDashboardDTO> factoryDashboardDTOList){
FactoryDashboardDTO data = new FactoryDashboardDTO();
data.setDeptName(sysDept.getDeptName());
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);
return data;
}
/**
* 获取当前时间半年内的保养数据
*/
private FactoryDashboardDTO getUpkeepDataByHalfYear(Long deptId){
FactoryDashboardDTO returnData = new FactoryDashboardDTO();
List<String> timeList = new ArrayList<>();
List<Object> dataList = new ArrayList<>();
List<Date> halfYearDate = getHalfYearDate();
//修改日期年月日
for (Date date : halfYearDate) {
FactoryDashboardDTO factoryData = factoryDashboardMapper.countUpkeepRecordNumByProductionLine(date,deptId);
String time = factoryData.getTime();
timeList.add(time.substring(0,time.lastIndexOf("-")));
dataList.add(factoryData.getData());
}
Collections.reverse(timeList);
Collections.reverse(dataList);
returnData.setX(timeList);
returnData.setY(dataList);
return returnData;
}
/**
* 获取当前时间半年内的时间并查询数据
*/
private FactoryDashboardDTO getMatenanceDataByHalfYear(Long deptId){
FactoryDashboardDTO returnData = new FactoryDashboardDTO();
List<String> timeList = new ArrayList<>();
List<Object> dataList = new ArrayList<>();
List<Date> halfYearDate = getHalfYearDate();
//修改日期年月日
for (Date date : halfYearDate) {
FactoryDashboardDTO factoryData = factoryDashboardMapper.countMaintenanceRecordNumByProductionLine(date,deptId);
String time = factoryData.getTime();
timeList.add(time.substring(0,time.lastIndexOf("-")));
dataList.add(factoryData.getData());
}
Collections.reverse(timeList);
Collections.reverse(dataList);
returnData.setX(timeList);
returnData.setY(dataList);
return returnData;
}
/**
* 获取当前时间内半年月份
*/
private List<Date> getHalfYearDate(){
LocalDate currentDate = LocalDate.now();
List<Date> halfYearDate = new ArrayList<>();
// 遍历当前日期之后的6个月包括当前月份
for (int i = 0; i < 6; i++) {
LocalDate firstDayOfMonth = currentDate.withDayOfMonth(1);
Date date = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
halfYearDate.add(date);
currentDate = currentDate.minusMonths(1L);
}
return halfYearDate;
}
}

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,73 @@
package com.inspur.bigscreen.task;
import com.inspur.bigscreen.domain.IpcDailyEquipNumByStatus;
import com.inspur.bigscreen.mapper.IpcDailyEquipNumByStatusMapper;
import com.inspur.common.core.domain.entity.SysDept;
import com.inspur.common.utils.spring.SpringUtils;
import com.inspur.equip.mapper.IpcEquipInfoMapper;
import com.inspur.system.mapper.SysDeptMapper;
import com.inspur.system.service.ISysDeptService;
import com.inspur.system.service.impl.SysDeptServiceImpl;
import org.springframework.aop.framework.AopContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 大屏数据统计定时任务
* @Author zhangjunwen
* @create 2024/7/11
*/
@Component("statsDataTask")
public class StatsDataTask {
@Resource
private ISysDeptService sysDeptService;
@Resource
private IpcDailyEquipNumByStatusMapper ipcDailyEquipNumByStatusMapper;
@Resource
private IpcEquipInfoMapper ipcEquipInfoMapper;
private static final Integer RUNNING = 0;
private static final Integer MAINTANANCE = 1;
private static final Integer STOP = 2;
/**
* 每日根据不同状态统计设备数量
*/
@Transactional
public void countDailyEquipNumByStatus(){
List<SysDept> deptList = sysDeptService.selectDeptAll();
List<SysDept> factoryList = deptList.stream().filter(dept -> dept.getAncestors().split(",").length == 4).collect(Collectors.toList());
for (SysDept sysDept : factoryList) {
int nums = 0;
//运行状态
insertIpcDailyEquipNumByStatusAndDeptId(RUNNING,sysDept.getDeptId());
//维修状态
insertIpcDailyEquipNumByStatusAndDeptId(MAINTANANCE,sysDept.getDeptId());
//停机状态
insertIpcDailyEquipNumByStatusAndDeptId(STOP,sysDept.getDeptId());
}
}
private int insertIpcDailyEquipNumByStatusAndDeptId(Integer status,Long deptId){
IpcDailyEquipNumByStatus ipcDailyEquipNumByStatus = new IpcDailyEquipNumByStatus();
ipcDailyEquipNumByStatus.setStatus(status);
int nums = ipcEquipInfoMapper.selectIpcEquipInfoNumByStatusAndDeptId(status,deptId);
ipcDailyEquipNumByStatus.setNums(nums);
ipcDailyEquipNumByStatus.setDeptId(deptId);
ipcDailyEquipNumByStatus.setCreateDate(new Date());
return ipcDailyEquipNumByStatusMapper.insertIpcDailyEquipNumByStatus(ipcDailyEquipNumByStatus);
}
}

View File

@ -6,6 +6,7 @@ import com.inspur.common.annotation.DataSource;
import com.inspur.common.enums.DataSourceType;
import com.inspur.equip.domain.EquipTreeSelect;
import com.inspur.equip.domain.IpcEquipInfo;
import org.apache.ibatis.annotations.Param;
public interface IpcEquipInfoMapper
@ -53,6 +54,13 @@ public interface IpcEquipInfoMapper
*/
public List<IpcEquipInfo> selectRunningIpcEquipInfoListByParentId(String parentEquipId);
/**
* 根据厂区id和设备状态查询设备数量
*/
public Integer selectIpcEquipInfoNumByStatusAndDeptId(@Param("status")Integer status,
@Param("deptId")Long deptId);
/**
* 新增设备信息
*

View File

@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Param;
* @Author zhangjunwen
* @create 2024/4/10
*/
@DataSource(DataSourceType.SLAVE)
public interface IpcAlarmRecordMapper
{
/**
@ -33,6 +33,11 @@ public interface IpcAlarmRecordMapper
*/
public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord);
/**
* 查询厂区id下最新的报警记录
*/
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId(Long deptId);
/**
* 新增报警记录
*

View File

@ -6,13 +6,7 @@ import com.inspur.common.annotation.DataSource;
import com.inspur.common.enums.DataSourceType;
import com.inspur.industrial.domain.IpcAlarmRules;
/**
* 设备报警规则Mapper接口
*
* @Author zhangjunwen
* @create 2024/4/9
*/
@DataSource(DataSourceType.SLAVE)
public interface IpcAlarmRulesMapper
{
/**

View File

@ -6,13 +6,7 @@ import com.inspur.industrial.domain.IpcFaultTreeConfig;
import java.util.List;
/**
* 故障树配置Mapper接口
*
* @author inspur
* @date 2024-04-02
*/
@DataSource(DataSourceType.SLAVE)
public interface IpcFaultTreeConfigMapper
{
/**

View File

@ -6,13 +6,7 @@ import com.inspur.common.annotation.DataSource;
import com.inspur.common.enums.DataSourceType;
import com.inspur.industrial.domain.IpcMonitorDataInfo;
/**
* 监控数据信息Mapper接口
*
* @author inspur
* @date 2024-04-09
*/
@DataSource(DataSourceType.SLAVE)
public interface IpcMonitorDataInfoMapper
{
/**

View File

@ -6,13 +6,7 @@ import com.inspur.common.annotation.DataSource;
import com.inspur.common.enums.DataSourceType;
import com.inspur.industrial.domain.IpcSysStatus;
/**
* 系统状态Mapper接口
*
* @Author zhangjunwen
* @create 2024/4/3
*/
@DataSource(DataSourceType.SLAVE)
public interface IpcSysStatusMapper
{
/**

View File

@ -6,7 +6,6 @@ import com.inspur.industrial.domain.PhmEquAlarmRecord;
import java.util.List;
@DataSource(DataSourceType.SLAVE)
public interface PhmEquAlarmRecordMapper {
/**
* 查询超压顶缸报警记录列表

View File

@ -29,6 +29,11 @@ public interface IIpcAlarmRecordService
*/
public List<IpcAlarmRecord> selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord);
/**
* 查询厂区id下最新的报警记录
*/
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId(Long deptId);
/**
* 新增报警记录
*

View File

@ -48,6 +48,13 @@ public class IpcAlarmRecordServiceImpl implements IIpcAlarmRecordService
return ipcAlarmRecordMapper.selectIpcAlarmRecordList(ipcAlarmRecord);
}
/**
* 查询厂区id下最新的报警记录
*/
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId(Long deptId){
return ipcAlarmRecordMapper.selectLatestIpcAlarmRecordByFactoryId(deptId);
}
/**
* 新增报警记录
*

View File

@ -19,6 +19,11 @@ public interface SysDeptMapper
*/
public List<SysDept> selectDeptList(SysDept dept);
/**
* 查询所有的部门数据
*/
public List<SysDept> selectDeptAll();
/**
* 根据角色ID查询部门树信息
*

View File

@ -19,6 +19,11 @@ public interface ISysDeptService
*/
public List<SysDept> selectDeptList(SysDept dept);
/**
* 查询所有部门数据
*/
public List<SysDept> selectDeptAll();
/**
* 查询部门树结构信息
*

View File

@ -48,6 +48,14 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.selectDeptList(dept);
}
/**
* 查询所有部门数据
*/
public List<SysDept> selectDeptAll(){
return deptMapper.selectDeptAll();
}
/**
* 查询部门树结构信息
*

View File

@ -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>

View File

@ -0,0 +1,126 @@
<?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})
and status != 3
GROUP BY dept_id;
</select>
<!--根据厂区部门id查询各个产线不同状态设备数-->
<select id="countEquipNumByStatusandProductionLine" resultMap="factoryData">
SELECT
d.dept_id,
d.dept_name,
COALESCE(ei.data, 0) AS data,
#{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>
<!--根据厂区部门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" resultMap="factoryData">
select a.click_date as time,ifnull(b.nums,0) as data
from
(<include refid="selectWeeklyDate"/>)
a left join
(
select nums,status,dept_id,DATE(create_date) as create_date
from `ipc_daily_equip_num_by_status`
where dept_id = #{deptId} and
create_date >= CURDATE() - INTERVAL 7 DAY
and `status` = #{status}
) b
on a.click_date = b.create_date
</select>
<!--统计近半年的维修记录数量-->
<select id="countMaintenanceRecordNumByProductionLine" resultMap="factoryData">
select #{date} as time,count(1) as data
from ipc_maintenance_record
where
MONTH(maintenance_start_time) = MONTH(#{date})
and YEAR(maintenance_start_time) = YEAR(#{date})
and dept_id = #{deptId}
</select>
<!-- 统计近半年的保养记录数量-->
<select id="countUpkeepRecordNumByProductionLine" resultMap="factoryData">
select #{date} as time,count(1) as data
from ipc_upkeep_plan
where
MONTH(plan_start_time) = MONTH(#{date})
and YEAR(plan_start_time) = YEAR(#{date})
and dept_id = #{deptId}
</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="nums" column="nums" />
<result property="status" column="status" />
<result property="deptId" column="dept_id" />
<result property="createDate" column="create_date" />
</resultMap>
<sql id="selectIpcDailyEquipNumByStatusVo">
select id, nums, 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="nums != null and nums != ''"> and nums = #{nums}</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="nums != null">nums,</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="nums != null">#{nums},</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="nums != null">nums = #{nums},</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

@ -144,6 +144,19 @@
WHERE parent_equip_id = #{parentEquipId} and status in ('0')
</select>
<!-- 根据设备状态查询设备数量
public Integer selectIpcEquipInfoNumByStatus(String status);-->
<select id="selectIpcEquipInfoNumByStatusAndDeptId" resultType="Integer">
select count(1)
from ipc_equip_info
where status = #{status}
and dept_id
in (
select dept_id from sys_dept
where find_in_set(#{deptId}, ancestors)
)
</select>
<insert id="insertIpcEquipInfo" parameterType="IpcEquipInfo">
insert into ipc_equip_info
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -27,6 +27,7 @@
<result property="equipManufacturer" column="equip_manufacturer" />
<result property="equipSerialNum" column="equip_serial_num" />
<result property="equipProductionDate" column="equip_production_date" />
<result property="deptName" column="dept_name" />
<result property="remark" column="remark" />
</resultMap>
@ -92,6 +93,23 @@
where a.id = #{id}
</select>
<!--查询厂区id下最新的报警记录
public List<IpcAlarmRecord> selectLatestIpcAlarmRecordByFactoryId-->
<select id="selectLatestIpcAlarmRecordByFactoryId" parameterType="Long" resultMap="IpcAlarmRecordResult">
select a.content,a.alarm_value,a.alarm_time,a.status,a.alarm_level,b.equip_name,c.dept_name
from `ipc_alarm_record` a
left join ipc_equip_info b
on a.equip_id = b.id
left join sys_dept c
on b.dept_id = c.dept_id
where b.dept_id in (
select dept_id from sys_dept where
find_in_set(103,ancestors)
)
order by a.alarm_time desc
limit 5
</select>
<insert id="insertIpcAlarmRecord" parameterType="IpcAlarmRecord" useGeneratedKeys="true" keyProperty="id">
insert into ipc_alarm_record
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -48,6 +48,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by d.parent_id, d.order_num
</select>
<select id="selectDeptAll" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
</select>
<select id="selectDeptListByRoleId" resultType="Long">
select d.dept_id
from sys_dept d

View File

@ -0,0 +1,66 @@
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",
});
}
//按照工厂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",
});
}

View File

@ -446,6 +446,20 @@ import { getToken } from "@/utils/auth";
import { Loading } from "element-ui";
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
import { deptTreeSelect } from "@/api/system/user";
import {
getEquipNumByProductionLine,
getEquipNumByStatusAndProductionLine,
getSensorNumByProductionLine,
getWeeklyAlarmNumByProductionLine,
getWeeklyEquipRunningNum,
getHYMaintenanceRecordNumByProductionLine,
getHYUpkeepRecordNumByProductionLine,
getLatestAlarmRecord,
} from "@/api/bigscreen/factory";
import {
getEquipNumByCompany,
getEquipNumByDiffCompany,
} from "@/api/bigscreen/company";
export default {
name: "Category",
components: {
@ -572,6 +586,10 @@ export default {
created() {
this.getList();
this.getDeptTree();
//
getEquipNumByDiffCompany(101).then((response) => {
console.log("data:", response.data);
});
},
methods: {
/** 查询部门下拉树结构 */