首页接口提交及对接

This commit is contained in:
xusd 2024-09-24 15:23:05 +08:00
parent ca37310b18
commit 03c743a440
11 changed files with 377 additions and 17 deletions

View File

@ -149,6 +149,12 @@
<version>6.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.inspur</groupId>
<artifactId>imt-module-bpm-biz</artifactId>
<version>2.2.0-jdk8-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,54 @@
package com.inspur.module.system.controller.imtIndex;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexMaintenanceOrderListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexTaskListVO;
import com.inspur.module.system.service.imtIndex.ImtIndexService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import static com.inspur.framework.common.pojo.CommonResult.success;
/**
* 首页
*
* @Author xusd
* @Date 2024/9/23 9:50
**/
@Tag(name = "首页")
@RestController
@RequestMapping("/admin-api/imt/imtIndex")
@Validated
public class ImtIndexController {
@Resource
private ImtIndexService imtIndexService;
@GetMapping("/taskList")
@Operation(summary = "我的待办")
public CommonResult<List<ImtIndexTaskListVO>> taskList() {
return success(imtIndexService.taskList());
}
@GetMapping("/alarmList")
@Operation(summary = "报警信息")
public CommonResult<List<ImtIndexAlarmListVO>> alarmList() {
return success(imtIndexService.alarmList());
}
@GetMapping("/maintenanceOrderList")
@Operation(summary = "维修工单")
public CommonResult<List<ImtIndexMaintenanceOrderListVO>> maintenanceOrderList() {
return success(imtIndexService.maintenanceOrderList());
}
}

View File

@ -0,0 +1,27 @@
package com.inspur.module.system.controller.imtIndex.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.inspur.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* @Author xusd
* @Date 2024/9/23 10:01
**/
@Data
public class ImtIndexAlarmListVO {
private String content;
private String customerName;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date lastAlarmTime;
private String equipNo;
}

View File

@ -0,0 +1,29 @@
package com.inspur.module.system.controller.imtIndex.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.inspur.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* @Author xusd
* @Date 2024/9/23 10:01
**/
@Data
public class ImtIndexMaintenanceOrderListVO {
private String customerId;
private String customerName;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date createTime;
private Integer faultType;
private Integer status;
}

View File

@ -0,0 +1,29 @@
package com.inspur.module.system.controller.imtIndex.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.inspur.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* @Author xusd
* @Date 2024/9/23 9:54
**/
@Data
public class ImtIndexTaskListVO {
private String processName;
private String name;
private String starter;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date createTime;
private String processInstanceId;
}

View File

@ -9,6 +9,7 @@ import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDO;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDTO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
@ -78,4 +79,7 @@ public interface AlarmDataMapper extends BaseMapperX<AlarmDataDO> {
* 根据规则id查询参数报警
*/
public AlarmDataDTO selectAlarmDataByRulesId(@Param("alarmRulesId") String alarmRulesId);
@TenantIgnore
List<ImtIndexAlarmListVO> selectListTop3();
}

View File

@ -0,0 +1,41 @@
package com.inspur.module.system.service.imtIndex;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexMaintenanceOrderListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexTaskListVO;
import java.util.List;
/**
* @Author xusd
* @Date 2024/9/23 9:51
**/
public interface ImtIndexService {
/**
* 我的待办
*
* @Author xusd
* @Date 9:58 2024/9/23
* @return java.util.List<com.inspur.module.system.controller.imtIndex.vo.ImtIndexTaskListVO>
*/
List<ImtIndexTaskListVO> taskList();
/**
* 报警信息
*
* @Author xusd
* @Date 9:59 2024/9/23
* @return java.util.List<com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO>
*/
List<ImtIndexAlarmListVO> alarmList();
/**
* 维修工单
*
* @Author xusd
* @Date 10:00 2024/9/23
* @return java.util.List<com.inspur.module.system.controller.imtIndex.vo.ImtIndexMaintenanceOrderListVO>
*/
List<ImtIndexMaintenanceOrderListVO> maintenanceOrderList();
}

View File

@ -0,0 +1,108 @@
package com.inspur.module.system.service.imtIndex;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.inspur.framework.common.util.number.NumberUtils;
import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.bpm.service.task.BpmProcessInstanceService;
import com.inspur.module.system.api.user.AdminUserApi;
import com.inspur.module.system.api.user.dto.AdminUserRespDTO;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoSelectionVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexMaintenanceOrderListVO;
import com.inspur.module.system.controller.imtIndex.vo.ImtIndexTaskListVO;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDO;
import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceOrderDO;
import com.inspur.module.system.dal.mysql.alarm.AlarmDataMapper;
import com.inspur.module.system.dal.mysql.maintenance.MaintenanceOrderMapper;
import com.inspur.module.system.service.baseData.CustomerInfoService;
import org.aspectj.weaver.ast.Var;
import org.flowable.engine.TaskService;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.inspur.framework.common.util.collection.CollectionUtils.convertSet;
import static com.inspur.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
/**
* @Author xusd
* @Date 2024/9/23 9:52
**/
@Service
public class ImtIndexServiceImpl implements ImtIndexService {
@Resource
private TaskService taskService;
@Resource
private BpmProcessInstanceService processInstanceService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private CustomerInfoService customerInfoService;
@Resource
private MaintenanceOrderMapper maintenanceOrderMapper;
@Resource
private AlarmDataMapper alarmDataMapper;
@Override
public List<ImtIndexTaskListVO> taskList() {
TaskQuery taskQuery = taskService.createTaskQuery()
.taskAssignee(String.valueOf(getLoginUserId())) // 分配给自己
.active()
.includeProcessVariables()
.orderByTaskCreateTime().desc();
List<Task> tasks = taskQuery.listPage(0, 5);
if (CollUtil.isEmpty(tasks)) {
return Collections.emptyList();
}
// 拼接数据
Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
convertSet(tasks, Task::getProcessInstanceId));
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
return BeanUtils.toBean(tasks, ImtIndexTaskListVO.class, taskVO -> {
ProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId());
if (processInstance == null) {
return;
}
taskVO.setProcessName(processInstance.getName());
AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
taskVO.setStarter(startUser.getNickname());
});
}
@Override
public List<ImtIndexAlarmListVO> alarmList() {
return alarmDataMapper.selectListTop3();
}
@Override
public List<ImtIndexMaintenanceOrderListVO> maintenanceOrderList() {
LambdaQueryWrapper<MaintenanceOrderDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.orderByDesc(MaintenanceOrderDO::getCreateTime);
queryWrapper.last("limit 3");
List<MaintenanceOrderDO> maintenanceOrderDOS = maintenanceOrderMapper.selectList(queryWrapper);
if (CollUtil.isEmpty(maintenanceOrderDOS)) {
return Collections.emptyList();
}
List<CustomerInfoSelectionVO> customerList = customerInfoService.selection(true);
Map<String, String> customerMap = customerList.stream().collect(Collectors.toMap(CustomerInfoSelectionVO::getCustomerId, CustomerInfoSelectionVO::getCustomerName));
return BeanUtils.toBean(maintenanceOrderDOS, ImtIndexMaintenanceOrderListVO.class, vo -> {
vo.setCustomerName(customerMap.get(vo.getCustomerId()));
});
}
}

View File

@ -24,6 +24,13 @@
<result property="componentName" column="component_name" />
</resultMap>
<resultMap id="selectListTop3" type="com.inspur.module.system.controller.imtIndex.vo.ImtIndexAlarmListVO">
<result property="content" column="content" />
<result property="lastAlarmTime" column="last_alarm_time" />
<result property="customerName" column="customer_name" />
<result property="equipNo" column="equip_no" />
</resultMap>
<sql id="selectAlarmDataVo">
select ad.alarm_data_id, ad.alarm_rules_id, ad.equip_id, ad.component_id, ad.name_key, ad.content, ad.alarm_value, ad.first_alarm_time, ad.last_alarm_time, ad.result, ad.status, ad.operator_id, ad.alarm_level, ad.reason_description, ad.equip_alarm_id,ad.alarm_type, ei.equip_no, ci.component_name, cui.customer_name,mi.model_name from imt_alarm_data ad
left join imt_equip_info ei on ad.equip_id = ei.equip_id
@ -57,4 +64,12 @@
and ad.status = 0
and ad.deleted = '0'
</select>
<select id="selectListTop3" resultMap="selectListTop3">
<include refid="selectAlarmDataVo"/>
where ad.status = 0
and ad.deleted = '0'
ORDER BY ad.last_alarm_time desc
limit 3
</select>
</mapper>

View File

@ -0,0 +1,25 @@
import request from '@/utils/request'
// 我的待办
export function getTaskList() {
return request({
url: '/imt/imtIndex/taskList',
method: 'get'
})
}
// 维修工单
export function getMaintenanceOrderList() {
return request({
url: '/imt/imtIndex/maintenanceOrderList',
method: 'get'
})
}
// 维修工单
export function getAlarmList() {
return request({
url: '/imt/imtIndex/alarmList',
method: 'get'
})
}

View File

@ -102,7 +102,7 @@
</div>
<el-table :data="taskList" :border="false" class="taskTable">
<el-table-column label="流程名称" align="center" prop="processName" :show-overflow-tooltip="true" />
<el-table-column label="任务名称" align="center" prop="taskName" :show-overflow-tooltip="true" />
<el-table-column label="任务名称" align="center" prop="name" :show-overflow-tooltip="true" />
<el-table-column label="发起人" align="center" prop="starter" :show-overflow-tooltip="true" />
<el-table-column label="任务时间" align="center" prop="createTime" width="180" :show-overflow-tooltip="true" />
</el-table>
@ -119,9 +119,9 @@
</div>
<el-table :data="alarmList" :border="false" class="taskTable">
<el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true" />
<el-table-column label="设备名称" align="center" prop="deviceName" :show-overflow-tooltip="true" />
<el-table-column label="报警信息" align="center" prop="alarmInfo" :show-overflow-tooltip="true" />
<el-table-column label="报警时间" align="center" prop="alarmTime" width="180" :show-overflow-tooltip="true" />
<el-table-column label="设备编号" align="center" prop="equipNo" :show-overflow-tooltip="true" />
<el-table-column label="报警信息" align="center" prop="content" :show-overflow-tooltip="true" />
<el-table-column label="报警时间" align="center" prop="lastAlarmTime" width="180" :show-overflow-tooltip="true" />
</el-table>
</el-card>
</el-col>
@ -134,9 +134,17 @@
</div>
<el-table :data="orderList" :border="false" class="taskTable">
<el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true" />
<el-table-column label="故障时间" align="center" prop="failureTime" :show-overflow-tooltip="true" />
<el-table-column label="故障类型" align="center" prop="failureType" :show-overflow-tooltip="true" />
<el-table-column label="进度" align="center" prop="progress" width="180" :show-overflow-tooltip="true" />
<el-table-column label="故障时间" align="center" prop="createTime" :show-overflow-tooltip="true" />
<el-table-column label="故障类型" align="center" prop="faultType" :show-overflow-tooltip="true" >
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.FAULT_TYPE" :value="scope.row.faultType"/>
</template>
</el-table-column>
<el-table-column label="进度" align="center" prop="status" width="180" :show-overflow-tooltip="true" >
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.MAINTENANCE_STATUS" :value="scope.row.status"/>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
@ -147,6 +155,8 @@
<script>
import LineChart from './home/LineChart'
import CountTo from 'vue-count-to'
import {getTaskList,getMaintenanceOrderList,getAlarmList} from '@/api/imtIndex'
import {DICT_TYPE} from "@/utils/dict";
const lineChartData = {
yData: [28, 27, 25, 26, 28, 22, 25, 25, 23, 27],
@ -155,6 +165,11 @@ const lineChartData = {
export default {
name: 'Index',
computed: {
DICT_TYPE() {
return DICT_TYPE
}
},
components: {
LineChart,
CountTo
@ -162,15 +177,9 @@ export default {
data() {
return {
lineChartData: lineChartData,
taskList: [{processName:'设备维修',taskName:'维修派单',starter:'张帆',createTime:'2024-09-13 10:56:27'},
{processName:'设备维修',taskName:'维修审批',starter:'吴恒',createTime:'2024-09-12 18:13:10'},
{processName:'设备维修',taskName:'维修评价',starter:'李科',createTime:'2024-09-12 16:29:12'}],
alarmList: [{customerName:'机加工一厂',deviceName:'钻工机床',alarmInfo:'X轴轴承电流过载',alarmTime:'2024-09-13 11:07:58'},
{customerName:'机加工二厂',deviceName:'硬轨机床',alarmInfo:'X轴排屑温度过高',alarmTime:'2024-09-13 10:27:28'},
{customerName:'机加工三厂',deviceName:'线轨机床',alarmInfo:'z轴轴承温度过高',alarmTime:'2024-09-12 15:09:18'}],
orderList: [{customerName:'机加工一厂',failureType:'轴承磨损',progress:'派工',failureTime:'2024-09-13 11:07:58'},
{customerName:'机加工二厂',failureType:'排屑堵塞',progress:'维修中',failureTime:'2024-09-13 10:27:28'},
{customerName:'机加工三厂',failureType:'机床底座不稳',progress:'待确认',failureTime:'2024-09-12 15:09:18'}],
taskList:[],
alarmList: [],
orderList: [],
groupData: {
customer: 5,
device: 28,
@ -188,11 +197,24 @@ export default {
titleImage:require('../assets/png/title.png'),
}
},
created() {
this.initData();
},
methods: {
/*handleSetLineChartData(type) {
this.lineChartData = lineChartData[type]
}*/
initData(){
getTaskList().then(res=>{
this.taskList = res.data;
})
getMaintenanceOrderList().then(res=>{
this.orderList = res.data;
})
getAlarmList().then(res=>{
this.alarmList = res.data;
})
},
goMytodo(){
this.$router.push({ path: "/bpm/task/todo" });
},