diff --git a/imt-server/imt-module-system/imt-module-system-biz/pom.xml b/imt-server/imt-module-system/imt-module-system-biz/pom.xml index fe229a6..156b480 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/pom.xml +++ b/imt-server/imt-module-system/imt-module-system-biz/pom.xml @@ -149,6 +149,12 @@ 6.8.0 compile + + com.inspur + imt-module-bpm-biz + 2.2.0-jdk8-snapshot + compile + diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/ImtIndexController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/ImtIndexController.java new file mode 100644 index 0000000..8924a9d --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/ImtIndexController.java @@ -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> taskList() { + return success(imtIndexService.taskList()); + } + + @GetMapping("/alarmList") + @Operation(summary = "报警信息") + public CommonResult> alarmList() { + return success(imtIndexService.alarmList()); + } + + @GetMapping("/maintenanceOrderList") + @Operation(summary = "维修工单") + public CommonResult> maintenanceOrderList() { + return success(imtIndexService.maintenanceOrderList()); + } + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexAlarmListVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexAlarmListVO.java new file mode 100644 index 0000000..1b024ec --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexAlarmListVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexMaintenanceOrderListVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexMaintenanceOrderListVO.java new file mode 100644 index 0000000..5427870 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexMaintenanceOrderListVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexTaskListVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexTaskListVO.java new file mode 100644 index 0000000..aa1324a --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/imtIndex/vo/ImtIndexTaskListVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmDataMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmDataMapper.java index 096a671..d06a4ab 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmDataMapper.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmDataMapper.java @@ -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 { * 根据规则id查询参数报警 */ public AlarmDataDTO selectAlarmDataByRulesId(@Param("alarmRulesId") String alarmRulesId); + + @TenantIgnore + List selectListTop3(); } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexService.java new file mode 100644 index 0000000..7423ef0 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexService.java @@ -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 + */ + List taskList(); + + /** + * 报警信息 + * + * @Author xusd + * @Date 9:59 2024/9/23 + * @return java.util.List + */ + List alarmList(); + + /** + * 维修工单 + * + * @Author xusd + * @Date 10:00 2024/9/23 + * @return java.util.List + */ + List maintenanceOrderList(); +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexServiceImpl.java new file mode 100644 index 0000000..99d0eb9 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/imtIndex/ImtIndexServiceImpl.java @@ -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 taskList() { + TaskQuery taskQuery = taskService.createTaskQuery() + .taskAssignee(String.valueOf(getLoginUserId())) // 分配给自己 + .active() + .includeProcessVariables() + .orderByTaskCreateTime().desc(); + List tasks = taskQuery.listPage(0, 5); + if (CollUtil.isEmpty(tasks)) { + return Collections.emptyList(); + } + // 拼接数据 + Map processInstanceMap = processInstanceService.getProcessInstanceMap( + convertSet(tasks, Task::getProcessInstanceId)); + Map 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 alarmList() { + return alarmDataMapper.selectListTop3(); + } + + @Override + public List maintenanceOrderList() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByDesc(MaintenanceOrderDO::getCreateTime); + queryWrapper.last("limit 3"); + List maintenanceOrderDOS = maintenanceOrderMapper.selectList(queryWrapper); + if (CollUtil.isEmpty(maintenanceOrderDOS)) { + return Collections.emptyList(); + } + List customerList = customerInfoService.selection(true); + Map customerMap = customerList.stream().collect(Collectors.toMap(CustomerInfoSelectionVO::getCustomerId, CustomerInfoSelectionVO::getCustomerName)); + return BeanUtils.toBean(maintenanceOrderDOS, ImtIndexMaintenanceOrderListVO.class, vo -> { + vo.setCustomerName(customerMap.get(vo.getCustomerId())); + }); + } +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/resources/mapper/alarm/AlarmDataMapper.xml b/imt-server/imt-module-system/imt-module-system-biz/src/main/resources/mapper/alarm/AlarmDataMapper.xml index 6ca6eac..edc17ad 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/resources/mapper/alarm/AlarmDataMapper.xml +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/resources/mapper/alarm/AlarmDataMapper.xml @@ -24,6 +24,13 @@ + + + + + + + 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' + + \ No newline at end of file diff --git a/imt-ui/src/api/imtIndex.js b/imt-ui/src/api/imtIndex.js new file mode 100644 index 0000000..4f62073 --- /dev/null +++ b/imt-ui/src/api/imtIndex.js @@ -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' + }) +} diff --git a/imt-ui/src/views/imtIndex.vue b/imt-ui/src/views/imtIndex.vue index 9d4bb9d..b35ad0f 100644 --- a/imt-ui/src/views/imtIndex.vue +++ b/imt-ui/src/views/imtIndex.vue @@ -102,7 +102,7 @@ - + @@ -119,9 +119,9 @@ - - - + + + @@ -134,9 +134,17 @@ - - - + + + + + + + @@ -147,6 +155,8 @@