Explorar o código

运行情况汇总

wanglt hai 3 meses
pai
achega
c3923ed166

+ 61 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/domain/GxtMonthRuntime.java

@@ -3,6 +3,7 @@ package com.ygtx.gxt.domain;
 import com.ygtx.common.core.domain.BaseEntity;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 月度场站运行天数工单对象 gxt_month_runtime
@@ -46,6 +47,18 @@ public class GxtMonthRuntime extends BaseEntity
 
     private String runtimeRange;
 
+    private Integer fromDays;
+
+    private Integer toDays;
+
+    private Integer stopNum;
+
+    private Integer runningNum;
+
+    private List<GxtRepairOrder> repairOrderList;
+
+    private List<GxtWorkOrder> workOrderList;
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -143,4 +156,52 @@ public class GxtMonthRuntime extends BaseEntity
     public void setRuntimeRange(String runtimeRange) {
         this.runtimeRange = runtimeRange;
     }
+
+    public Integer getFromDays() {
+        return fromDays;
+    }
+
+    public void setFromDays(Integer fromDays) {
+        this.fromDays = fromDays;
+    }
+
+    public Integer getToDays() {
+        return toDays;
+    }
+
+    public void setToDays(Integer toDays) {
+        this.toDays = toDays;
+    }
+
+    public Integer getStopNum() {
+        return stopNum;
+    }
+
+    public void setStopNum(Integer stopNum) {
+        this.stopNum = stopNum;
+    }
+
+    public Integer getRunningNum() {
+        return runningNum;
+    }
+
+    public void setRunningNum(Integer runningNum) {
+        this.runningNum = runningNum;
+    }
+
+    public List<GxtRepairOrder> getRepairOrderList() {
+        return repairOrderList;
+    }
+
+    public void setRepairOrderList(List<GxtRepairOrder> repairOrderList) {
+        this.repairOrderList = repairOrderList;
+    }
+
+    public List<GxtWorkOrder> getWorkOrderList() {
+        return workOrderList;
+    }
+
+    public void setWorkOrderList(List<GxtWorkOrder> workOrderList) {
+        this.workOrderList = workOrderList;
+    }
 }

+ 30 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/domain/GxtWorkOrder.java

@@ -296,6 +296,12 @@ public class GxtWorkOrder extends BaseEntity
 
     private String leader;
 
+    private Integer stopDays;
+
+    private Integer runningDays;
+
+    private String deptName;
+
     public void setId(Long id)
     {
         this.id = id;
@@ -973,6 +979,30 @@ public class GxtWorkOrder extends BaseEntity
         this.leader = leader;
     }
 
+    public Integer getStopDays() {
+        return stopDays;
+    }
+
+    public void setStopDays(Integer stopDays) {
+        this.stopDays = stopDays;
+    }
+
+    public Integer getRunningDays() {
+        return runningDays;
+    }
+
+    public void setRunningDays(Integer runningDays) {
+        this.runningDays = runningDays;
+    }
+
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 4 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/mapper/GxtWorkOrderMapper.java

@@ -114,6 +114,10 @@ public interface GxtWorkOrderMapper {
     public int updateGxtWorkOrderByDeferred(GxtWorkOrder gxtWorkOrder);
 
     public List<GxtOrderData> selectHomePageWorkOrderList(GxtOrderData gxtOrderData);
+
+    public List<GxtWorkOrder> selectGxtWorkOrderRunningDaysInfo(GxtWorkOrder workOrder);
+
+    public List<GxtWorkOrder> selectGxtRepairOrderRunningDaysInfo(GxtWorkOrder workOrder);
     
     /**
      * 查询设备最近的维保工单

+ 3 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/IGxtMonthRuntimeService.java

@@ -2,6 +2,7 @@ package com.ygtx.gxt.service;
 
 import java.util.List;
 import com.ygtx.gxt.domain.GxtMonthRuntime;
+import com.ygtx.gxt.domain.GxtWorkOrder;
 
 /**
  * 月度场站运行天数工单Service接口
@@ -27,6 +28,8 @@ public interface IGxtMonthRuntimeService
      */
     public List<GxtMonthRuntime> selectGxtMonthRuntimeList(GxtMonthRuntime gxtMonthRuntime);
 
+    public List<GxtWorkOrder> getOrders(Long pid, Integer fromDays, Integer toDays, boolean isStop);
+
     /**
      * 新增月度场站运行天数工单
      * 

+ 557 - 2
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtMonthRuntimeServiceImpl.java

@@ -1,6 +1,21 @@
 package com.ygtx.gxt.service.impl;
 
-import java.util.List;
+import java.util.*;
+
+import com.ygtx.common.core.domain.entity.SysDept;
+import com.ygtx.common.core.domain.entity.SysRole;
+import com.ygtx.common.core.domain.entity.SysUser;
+import com.ygtx.common.core.domain.model.LoginUser;
+import com.ygtx.common.utils.SecurityUtils;
+import com.ygtx.common.utils.StringUtils;
+import com.ygtx.framework.aspectj.DataScopeAspect;
+import com.ygtx.gxt.domain.GxtRepairOrder;
+import com.ygtx.gxt.domain.GxtSafeOperationReward;
+import com.ygtx.gxt.domain.GxtWorkOrder;
+import com.ygtx.gxt.mapper.GxtRepairOrderMapper;
+import com.ygtx.gxt.mapper.GxtSafeOperationRewardMapper;
+import com.ygtx.gxt.mapper.GxtWorkOrderMapper;
+import com.ygtx.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ygtx.gxt.mapper.GxtMonthRuntimeMapper;
@@ -19,6 +34,15 @@ public class GxtMonthRuntimeServiceImpl implements IGxtMonthRuntimeService
     @Autowired
     private GxtMonthRuntimeMapper gxtMonthRuntimeMapper;
 
+    @Autowired
+    private GxtWorkOrderMapper gxtWorkOrderMapper;
+
+    @Autowired
+    private GxtSafeOperationRewardMapper safeOperationRewardMapper;
+
+    @Autowired
+    private ISysConfigService configService;
+
     /**
      * 查询月度场站运行天数工单
      * 
@@ -40,7 +64,538 @@ public class GxtMonthRuntimeServiceImpl implements IGxtMonthRuntimeService
     @Override
     public List<GxtMonthRuntime> selectGxtMonthRuntimeList(GxtMonthRuntime gxtMonthRuntime)
     {
-        return gxtMonthRuntimeMapper.selectGxtMonthRuntimeList(gxtMonthRuntime);
+        List<GxtWorkOrder> workOrders = getOrdersByPid(gxtMonthRuntime.getDeptName(),null);
+        List<GxtMonthRuntime> result = new ArrayList<>();
+        if (!workOrders.isEmpty()) {
+            GxtSafeOperationReward safeOperationReward = new GxtSafeOperationReward();
+            safeOperationReward.setStatus(0);
+            List<GxtSafeOperationReward> safeList = safeOperationRewardMapper.selectGxtSafeOperationRewardList(safeOperationReward);
+            if (!safeList.isEmpty()) {
+                Collections.sort(safeList, new Comparator<GxtSafeOperationReward>() {
+                    @Override
+                    public int compare(GxtSafeOperationReward o1, GxtSafeOperationReward o2) {
+                        return o2.getSafeDuration().compareTo(o1.getSafeDuration());
+                    }
+                });
+                for (int i=0;i<safeList.size();i++) {
+                    GxtSafeOperationReward safe = safeList.get(i);
+                    Integer fromDays = safe.getSafeDuration();
+                    Integer toDays = null;
+                    if (i>0) {
+                        toDays = safeList.get(i-1).getSafeDuration();
+                    }
+                    for (GxtWorkOrder workOrder:workOrders) {
+                        // 停运时长计算
+                        if (workOrder.getStopDays()>=fromDays && (toDays==null||workOrder.getStopDays()<toDays)) {
+                            boolean isAdd = true;
+                            String runtimeRange = "≥" + fromDays + "天";
+                            if (!result.isEmpty()) {
+                                for (GxtMonthRuntime runtime:result) {
+                                    if (Objects.equals(runtime.getDeptId(), workOrder.getPcsStationPid()) && runtime.getRuntimeRange().equals(runtimeRange)) {
+                                        isAdd = false;
+                                        runtime.setStopNum(runtime.getStopNum()+1);
+                                        break;
+                                    }
+                                }
+                            }
+                            if (isAdd) {
+                                GxtMonthRuntime addRuntime = new GxtMonthRuntime();
+                                addRuntime.setDeptName(workOrder.getDeptName());
+                                addRuntime.setDeptId(workOrder.getPcsStationPid());
+                                addRuntime.setFromDays(fromDays);
+                                addRuntime.setToDays(toDays);
+                                addRuntime.setRuntimeRange(runtimeRange);
+                                addRuntime.setStopNum(1);
+                                addRuntime.setRunningNum(0);
+                                result.add(addRuntime);
+                            }
+                        }
+                        // 持续运行时长计算
+                        if (workOrder.getRunningDays()>=fromDays && (toDays==null||workOrder.getRunningDays()<toDays)) {
+                            boolean isAdd = true;
+                            String runtimeRange = "≥" + fromDays + "天";
+                            if (!result.isEmpty()) {
+                                for (GxtMonthRuntime runtime:result) {
+                                    if (Objects.equals(runtime.getDeptId(), workOrder.getPcsStationPid()) && runtime.getRuntimeRange().equals(runtimeRange)) {
+                                        isAdd = false;
+                                        runtime.setRunningNum(runtime.getRunningNum()+1);
+                                        break;
+                                    }
+                                }
+                            }
+                            if (isAdd) {
+                                GxtMonthRuntime addRuntime = new GxtMonthRuntime();
+                                addRuntime.setDeptName(workOrder.getDeptName());
+                                addRuntime.setDeptId(workOrder.getPcsStationPid());
+                                addRuntime.setFromDays(fromDays);
+                                addRuntime.setToDays(toDays);
+                                addRuntime.setRuntimeRange(runtimeRange);
+                                addRuntime.setStopNum(0);
+                                addRuntime.setRunningNum(1);
+                                result.add(addRuntime);
+                            }
+                        }
+                    }
+                }
+            }
+            Collections.sort(result, new Comparator<GxtMonthRuntime>() {
+                @Override
+                public int compare(GxtMonthRuntime o1, GxtMonthRuntime o2) {
+                    int deptCompare = o1.getDeptName().compareTo(o2.getDeptName());
+                    if (deptCompare != 0) {
+                        return deptCompare;
+                    }
+                    return o1.getFromDays().compareTo(o2.getFromDays());
+                }
+            });
+        }
+        return result;
+    }
+
+    public List<GxtWorkOrder> getOrdersByPid(String searchName,Long pid) {
+        GxtWorkOrder searchOrder = new GxtWorkOrder();
+        searchOrder.setPcsStationPid(pid);
+        searchOrder.setDeptName(searchName);
+        addBusinessDataScopeFilter(searchOrder);
+        GxtWorkOrder searchRepairOrder = new GxtWorkOrder();
+        searchRepairOrder.setPcsStationPid(pid);
+        searchRepairOrder.setDeptName(searchName);
+        addBusinessDataScopeFilterRepair(searchRepairOrder);
+        List<GxtWorkOrder> workOrders = new ArrayList<>();
+        List<GxtWorkOrder> workOrderList = gxtWorkOrderMapper.selectGxtWorkOrderRunningDaysInfo(searchOrder);
+        List<GxtWorkOrder> repairOrderList = gxtWorkOrderMapper.selectGxtRepairOrderRunningDaysInfo(searchRepairOrder);
+        if (!workOrderList.isEmpty() && !repairOrderList.isEmpty()) {
+            workOrders.addAll(repairOrderList);
+            for (GxtWorkOrder workOrder:workOrderList) {
+                boolean isAdd = true;
+                GxtWorkOrder repairAdd = null;
+                for (GxtWorkOrder repairOrder:repairOrderList) {
+                    if (workOrder.getPcsDeviceId()==repairOrder.getPcsDeviceId()) {
+                        isAdd = false;
+                        if (workOrder.getPauseTime().compareTo(repairOrder.getPauseTime())>=0) {
+                            repairAdd = repairOrder;
+                        }
+                        break;
+                    }
+                }
+                if (isAdd) {
+                    workOrders.add(workOrder);
+                } else if (repairAdd!=null) {
+                    workOrders.remove(repairAdd);
+                    workOrders.add(workOrder);
+                }
+            }
+        } else if (!workOrderList.isEmpty()) {
+            workOrders.addAll(workOrderList);
+        } else if (!repairOrderList.isEmpty()) {
+            workOrders.addAll(repairOrderList);
+        }
+        if (!workOrders.isEmpty()) {
+            Collections.sort(workOrders, new Comparator<GxtWorkOrder>() {
+                @Override
+                public int compare(GxtWorkOrder o1, GxtWorkOrder o2) {
+                    int deptCompare = o1.getDeptName().compareTo(o2.getDeptName());
+                    if (deptCompare != 0) {
+                        return deptCompare;
+                    }
+                    return o1.getWorkOrderProjectNo().compareTo(o2.getWorkOrderProjectNo());
+                }
+            });
+        }
+        return workOrders;
+    }
+
+    @Override
+    public List<GxtWorkOrder> getOrders(Long pid,Integer fromDays,Integer toDays,boolean isStop) {
+        List<GxtWorkOrder> workOrders = getOrdersByPid(null,pid);
+        List<GxtWorkOrder> result = new ArrayList<>();
+        if (!workOrders.isEmpty()) {
+            for (GxtWorkOrder order:workOrders) {
+                if (isStop) {
+                    if (order.getStopDays()>=fromDays && (toDays==null || order.getStopDays()<toDays)) {
+                        result.add(order);
+                    }
+                }else {
+                    if (order.getRunningDays()>=fromDays && (toDays==null || order.getRunningDays()<toDays)) {
+                        result.add(order);
+                    }
+                }
+            }
+        }
+        if (!result.isEmpty()) {
+            Collections.sort(result, new Comparator<GxtWorkOrder>() {
+                @Override
+                public int compare(GxtWorkOrder o1, GxtWorkOrder o2) {
+                    int deptCompare = o1.getDeptName().compareTo(o2.getDeptName());
+                    if (deptCompare != 0) {
+                        return deptCompare;
+                    }
+                    return o1.getWorkOrderProjectNo().compareTo(o2.getWorkOrderProjectNo());
+                }
+            });
+        }
+        return result;
+    }
+
+    /**
+     * 添加业务特定的数据权限过滤条件
+     * 基于角色的数据范围进行自定义权限控制
+     *
+     * @param gxtWorkOrder 保工单查询条件
+     */
+    private void addBusinessDataScopeFilter(GxtWorkOrder gxtWorkOrder) {
+        // 获取当前登录用户
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null) {
+            return;
+        }
+
+        SysUser currentUser = loginUser.getUser();
+        if (currentUser == null) {
+            return;
+        }
+
+        // 如果是超级管理员,不过滤数据
+        if (currentUser.isAdmin()) {
+            return;
+        }
+
+        // 获取用户角色
+        List<SysRole> roles = currentUser.getRoles();
+        if (roles == null || roles.isEmpty()) {
+            return;
+        }
+
+        // 检查是否有"全部数据"权限的角色,如果有则不过滤
+        boolean hasAllDataPermission = roles.stream()
+                .anyMatch(role -> DataScopeAspect.DATA_SCOPE_ALL.equals(role.getDataScope()));
+
+        // 如果有任何一个角色有全部数据权限,则不过滤
+        if (!hasAllDataPermission) {
+            // 构建业务特定的数据权限SQL
+            StringBuilder businessSql = new StringBuilder();
+
+            // 遍历用户角色,根据角色的数据范围添加业务特定的权限控制
+            for (SysRole role : roles) {
+                String dataScope = role.getDataScope();
+
+                // 自定义数据权限 - 根据角色的数据范围值来控制查询条件
+                if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(dataScope)) {
+                    // 获取具有自定义数据权限的角色ID列表
+                    List<String> customRoleIds = new ArrayList<>();
+                    for (SysRole r : roles) {
+                        if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) {
+                            customRoleIds.add(String.valueOf(r.getRoleId()));
+                        }
+                    }
+
+                    // 构建自定义数据权限查询条件
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+
+                    if (customRoleIds.size() > 1) {
+                        // 多个自定义数据权限角色使用IN查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append(")))");
+                    } else {
+                        // 单个自定义数据权限角色查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append("))");
+                    }
+                    continue;
+                }
+
+                // 部门数据权限 - 适用于部门负责人角色
+                if (DataScopeAspect.DATA_SCOPE_DEPT.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.pcs_station_pid = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.gxt_center_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(")");
+                    continue;
+                }
+
+                // 部门及以下数据权限
+                if (DataScopeAspect.DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.pcs_station_pid IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.gxt_center_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors)))");
+                    continue;
+                }
+
+                // 仅本人数据权限 - 适用于主检修员角色
+                if (DataScopeAspect.DATA_SCOPE_SELF.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.team_leader_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.assign_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.accept_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.id IN (SELECT order_id FROM gxt_work_order_person WHERE user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(") ")
+                            .append(" OR t.create_by = '")
+                            .append(currentUser.getUserName())
+                            .append("')");
+                    continue;
+                }
+            }
+            String selfData = configService.selectConfigByKey("gxt.oder.selfData");
+            if (StringUtils.isNotEmpty(selfData) && "1".equals(selfData)) {
+                if (businessSql.length() > 0) {
+                    businessSql.append(" OR ");
+                }
+                businessSql.append("(t.team_leader_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.assign_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.accept_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.id IN (SELECT order_id FROM gxt_work_order_person WHERE user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(") ")
+                        .append(" OR t.create_by = '")
+                        .append(currentUser.getUserName())
+                        .append("')");
+            }
+            // 如果构建了业务特定的过滤条件,则添加到查询参数中
+            if (businessSql.length() > 0) {
+                String businessDataScopeSql = " AND (" + businessSql.toString() + ")";
+                gxtWorkOrder.getParams().put("businessDataScope", businessDataScopeSql);
+            }
+        }
+        // 对于已作废(work_order_status = 'invalid')的工单,只有admin用户才能查看
+        if (!SecurityUtils.isAdmin(currentUser.getUserId())) {
+            String invalidFilterSql = " AND (t.work_order_status != 'invalid')";
+            if (gxtWorkOrder.getParams().get("businessDataScope") != null) {
+                String existingSql = gxtWorkOrder.getParams().get("businessDataScope").toString();
+                gxtWorkOrder.getParams().put("businessDataScope", existingSql + invalidFilterSql);
+            } else {
+                gxtWorkOrder.getParams().put("businessDataScope", invalidFilterSql);
+            }
+        }
+    }
+
+
+    /**
+     * 添加业务特定的数据权限过滤条件
+     * 基于角色的数据范围进行自定义权限控制
+     *
+     * @param repairOrder 保工单查询条件
+     */
+    private void addBusinessDataScopeFilterRepair(GxtWorkOrder repairOrder) {
+        // 获取当前登录用户
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null) {
+            return;
+        }
+
+        SysUser currentUser = loginUser.getUser();
+        if (currentUser == null) {
+            return;
+        }
+
+        // 如果是超级管理员,不过滤数据
+        if (currentUser.isAdmin()) {
+            return;
+        }
+
+        // 获取用户角色
+        List<SysRole> roles = currentUser.getRoles();
+        if (roles == null || roles.isEmpty()) {
+            return;
+        }
+
+        // 检查是否有"全部数据"权限的角色,如果有则不过滤
+        boolean hasAllDataPermission = roles.stream()
+                .anyMatch(role -> DataScopeAspect.DATA_SCOPE_ALL.equals(role.getDataScope()));
+
+        // 如果有任何一个角色有全部数据权限,则不过滤
+        if (!hasAllDataPermission) {
+            // 构建业务特定的数据权限SQL
+            StringBuilder businessSql = new StringBuilder();
+
+            // 遍历用户角色,根据角色的数据范围添加业务特定的权限控制
+            for (SysRole role : roles) {
+                String dataScope = role.getDataScope();
+
+                // 自定义数据权限 - 根据角色的数据范围值来控制查询条件
+                if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(dataScope)) {
+                    // 获取具有自定义数据权限的角色ID列表
+                    List<String> customRoleIds = new ArrayList<>();
+                    for (SysRole r : roles) {
+                        if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) {
+                            customRoleIds.add(String.valueOf(r.getRoleId()));
+                        }
+                    }
+
+                    // 构建自定义数据权限查询条件
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+
+                    if (customRoleIds.size() > 1) {
+                        // 多个自定义数据权限角色使用IN查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append(")))");
+                    } else {
+                        // 单个自定义数据权限角色查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append("))");
+                    }
+                    continue;
+                }
+
+                // 部门数据权限 - 适用于部门负责人角色
+                if (DataScopeAspect.DATA_SCOPE_DEPT.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.pcs_station_pid = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.gxt_center_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(")");
+                    continue;
+                }
+
+                // 部门及以下数据权限
+                if (DataScopeAspect.DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.pcs_station_pid IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.gxt_center_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors)))");
+                    continue;
+                }
+
+                // 仅本人数据权限 - 适用于主检修员角色
+                if (DataScopeAspect.DATA_SCOPE_SELF.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.team_leader_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.assign_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.accept_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.id IN (SELECT order_id FROM gxt_repair_order_person WHERE user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(") ")
+                            .append(" OR t.create_by = '")
+                            .append(currentUser.getUserName())
+                            .append("')");
+                    continue;
+                }
+            }
+            String selfData = configService.selectConfigByKey("gxt.oder.selfData");
+            if (StringUtils.isNotEmpty(selfData) && "1".equals(selfData)) {
+                if (businessSql.length() > 0) {
+                    businessSql.append(" OR ");
+                }
+                businessSql.append("(t.team_leader_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.assign_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.accept_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.id IN (SELECT order_id FROM gxt_repair_order_person WHERE user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(") ")
+                        .append(" OR t.create_by = '")
+                        .append(currentUser.getUserName())
+                        .append("')");
+            }
+            // 如果构建了业务特定的过滤条件,则添加到查询参数中
+            if (businessSql.length() > 0) {
+                String businessDataScopeSql = " AND (" + businessSql.toString() + ")";
+                repairOrder.getParams().put("businessDataScope", businessDataScopeSql);
+            }
+        }
+        // 对于已作废(work_order_status = 'invalid')的工单,只有admin用户才能查看
+        if (!SecurityUtils.isAdmin(currentUser.getUserId())) {
+            String invalidFilterSql = " AND (t.work_order_status != 'invalid')";
+            if (repairOrder.getParams().get("businessDataScope") != null) {
+                String existingSql = repairOrder.getParams().get("businessDataScope").toString();
+                repairOrder.getParams().put("businessDataScope", existingSql + invalidFilterSql);
+            } else {
+                repairOrder.getParams().put("businessDataScope", invalidFilterSql);
+            }
+        }
     }
 
     /**

+ 376 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtMonthScoreServiceImpl.java

@@ -9,8 +9,12 @@ import java.util.*;
 import java.time.format.DateTimeFormatter;
 
 import com.ygtx.common.core.domain.entity.SysDept;
+import com.ygtx.common.core.domain.entity.SysRole;
 import com.ygtx.common.core.domain.entity.SysUser;
+import com.ygtx.common.core.domain.model.LoginUser;
 import com.ygtx.common.utils.SecurityUtils;
+import com.ygtx.common.utils.StringUtils;
+import com.ygtx.framework.aspectj.DataScopeAspect;
 import com.ygtx.gxt.domain.*;
 import com.ygtx.gxt.mapper.*;
 import com.ygtx.system.domain.SysPostHomePage;
@@ -18,6 +22,7 @@ import com.ygtx.system.mapper.SysDeptMapper;
 import com.ygtx.system.mapper.SysPostHomePageMapper;
 import com.ygtx.system.mapper.SysRoleMapper;
 import com.ygtx.system.mapper.SysUserMapper;
+import com.ygtx.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ygtx.gxt.service.IGxtMonthScoreService;
@@ -79,6 +84,9 @@ public class GxtMonthScoreServiceImpl implements IGxtMonthScoreService
     @Autowired
     private SysPostHomePageMapper sysPostHomePageMapper;
 
+    @Autowired
+    private ISysConfigService configService;
+
     /**
      * 查询月度统计表
      * 
@@ -105,15 +113,383 @@ public class GxtMonthScoreServiceImpl implements IGxtMonthScoreService
         workOrder.setInspectionType(inspectionTypeId);
         workOrder.setPcsStationPid(pid);
         workOrder.setMonthPeriod(monthPeriod);
+        addBusinessDataScopeFilter(workOrder);
         return gxtWorkOrderMapper.selectGxtWorkOrderListByMonth(workOrder);
     }
 
+
+
+    /**
+     * 添加业务特定的数据权限过滤条件
+     * 基于角色的数据范围进行自定义权限控制
+     *
+     * @param gxtWorkOrder 维保工单查询条件
+     */
+    private void addBusinessDataScopeFilter(GxtWorkOrder gxtWorkOrder) {
+        // 获取当前登录用户
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null) {
+            return;
+        }
+
+        SysUser currentUser = loginUser.getUser();
+        if (currentUser == null) {
+            return;
+        }
+
+        // 如果是超级管理员,不过滤数据
+        if (currentUser.isAdmin()) {
+            return;
+        }
+
+        // 获取用户角色
+        List<SysRole> roles = currentUser.getRoles();
+        if (roles == null || roles.isEmpty()) {
+            return;
+        }
+
+        // 检查是否有"全部数据"权限的角色,如果有则不过滤
+        boolean hasAllDataPermission = roles.stream()
+                .anyMatch(role -> DataScopeAspect.DATA_SCOPE_ALL.equals(role.getDataScope()));
+
+        // 如果有任何一个角色有全部数据权限,则不过滤
+        if (!hasAllDataPermission) {
+            // 构建业务特定的数据权限SQL
+            StringBuilder businessSql = new StringBuilder();
+
+            // 遍历用户角色,根据角色的数据范围添加业务特定的权限控制
+            for (SysRole role : roles) {
+                String dataScope = role.getDataScope();
+
+                // 自定义数据权限 - 根据角色的数据范围值来控制查询条件
+                if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(dataScope)) {
+                    // 获取具有自定义数据权限的角色ID列表
+                    List<String> customRoleIds = new ArrayList<>();
+                    for (SysRole r : roles) {
+                        if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) {
+                            customRoleIds.add(String.valueOf(r.getRoleId()));
+                        }
+                    }
+
+                    // 构建自定义数据权限查询条件
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+
+                    if (customRoleIds.size() > 1) {
+                        // 多个自定义数据权限角色使用IN查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append(")))");
+                    } else {
+                        // 单个自定义数据权限角色查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append("))");
+                    }
+                    continue;
+                }
+
+                // 部门数据权限 - 适用于部门负责人角色
+                if (DataScopeAspect.DATA_SCOPE_DEPT.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.pcs_station_pid = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.gxt_center_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(")");
+                    continue;
+                }
+
+                // 部门及以下数据权限
+                if (DataScopeAspect.DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.pcs_station_pid IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.gxt_center_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors)))");
+                    continue;
+                }
+
+                // 仅本人数据权限 - 适用于主检修员角色
+                if (DataScopeAspect.DATA_SCOPE_SELF.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.team_leader_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.assign_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.accept_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.id IN (SELECT order_id FROM gxt_work_order_person WHERE user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(") ")
+                            .append(" OR t.create_by = '")
+                            .append(currentUser.getUserName())
+                            .append("')");
+                    continue;
+                }
+            }
+            String selfData = configService.selectConfigByKey("gxt.oder.selfData");
+            if (StringUtils.isNotEmpty(selfData) && "1".equals(selfData)) {
+                if (businessSql.length() > 0) {
+                    businessSql.append(" OR ");
+                }
+                businessSql.append("(t.team_leader_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.assign_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.accept_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.id IN (SELECT order_id FROM gxt_work_order_person WHERE user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(") ")
+                        .append(" OR t.create_by = '")
+                        .append(currentUser.getUserName())
+                        .append("')");
+            }
+            // 如果构建了业务特定的过滤条件,则添加到查询参数中
+            if (businessSql.length() > 0) {
+                String businessDataScopeSql = " AND (" + businessSql.toString() + ")";
+                gxtWorkOrder.getParams().put("businessDataScope", businessDataScopeSql);
+            }
+        }
+        // 对于已作废(work_order_status = 'invalid')的工单,只有admin用户才能查看
+        if (!SecurityUtils.isAdmin(currentUser.getUserId())) {
+            String invalidFilterSql = " AND (t.work_order_status != 'invalid')";
+            if (gxtWorkOrder.getParams().get("businessDataScope") != null) {
+                String existingSql = gxtWorkOrder.getParams().get("businessDataScope").toString();
+                gxtWorkOrder.getParams().put("businessDataScope", existingSql + invalidFilterSql);
+            } else {
+                gxtWorkOrder.getParams().put("businessDataScope", invalidFilterSql);
+            }
+        }
+    }
+
+
+
+
+
+    /**
+     * 添加业务特定的数据权限过滤条件
+     * 基于角色的数据范围进行自定义权限控制
+     *
+     * @param gxtRepairOrder 维修工单查询条件
+     */
+    private void addBusinessDataScopeFilter(GxtRepairOrder gxtRepairOrder) {
+        // 获取当前登录用户
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (loginUser == null) {
+            return;
+        }
+
+        SysUser currentUser = loginUser.getUser();
+        if (currentUser == null) {
+            return;
+        }
+
+        // 如果是超级管理员,不过滤数据
+        if (currentUser.isAdmin()) {
+            return;
+        }
+
+        // 获取用户角色
+        List<SysRole> roles = currentUser.getRoles();
+        if (roles == null || roles.isEmpty()) {
+            return;
+        }
+
+        // 检查是否有"全部数据"权限的角色,如果有则不过滤
+        boolean hasAllDataPermission = roles.stream()
+                .anyMatch(role -> DataScopeAspect.DATA_SCOPE_ALL.equals(role.getDataScope()));
+
+        // 如果有任何一个角色有全部数据权限,则不过滤
+        if (!hasAllDataPermission) {
+            // 构建业务特定的数据权限SQL
+            StringBuilder businessSql = new StringBuilder();
+
+            // 遍历用户角色,根据角色的数据范围添加业务特定的权限控制
+            for (SysRole role : roles) {
+                String dataScope = role.getDataScope();
+
+                // 自定义数据权限 - 根据角色的数据范围值来控制查询条件
+                if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(dataScope)) {
+                    // 获取具有自定义数据权限的角色ID列表
+                    List<String> customRoleIds = new ArrayList<>();
+                    for (SysRole r : roles) {
+                        if (DataScopeAspect.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) {
+                            customRoleIds.add(String.valueOf(r.getRoleId()));
+                        }
+                    }
+
+                    // 构建自定义数据权限查询条件
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+
+                    if (customRoleIds.size() > 1) {
+                        // 多个自定义数据权限角色使用IN查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append("))")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id IN (")
+                                .append(String.join(",", customRoleIds))
+                                .append(")))");
+                    } else {
+                        // 单个自定义数据权限角色查询
+                        businessSql.append("(t.pcs_station_pid IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.pcs_station_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append(")")
+                                .append(" OR t.gxt_center_id IN (SELECT dept_id FROM sys_role_dept WHERE role_id = ")
+                                .append(role.getRoleId())
+                                .append("))");
+                    }
+                    continue;
+                }
+
+                // 部门数据权限 - 适用于部门负责人角色
+                if (DataScopeAspect.DATA_SCOPE_DEPT.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.pcs_station_pid = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR t.gxt_center_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(")");
+                    continue;
+                }
+
+                // 部门及以下数据权限
+                if (DataScopeAspect.DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.pcs_station_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.pcs_station_pid IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors))")
+                            .append(" OR t.gxt_center_id IN ")
+                            .append("(SELECT dept_id FROM sys_dept WHERE dept_id = ")
+                            .append(currentUser.getDeptId())
+                            .append(" OR FIND_IN_SET(")
+                            .append(currentUser.getDeptId())
+                            .append(", ancestors)))");
+                    continue;
+                }
+
+                // 仅本人数据权限 - 适用于主检修员角色
+                if (DataScopeAspect.DATA_SCOPE_SELF.equals(dataScope)) {
+                    if (businessSql.length() > 0) {
+                        businessSql.append(" OR ");
+                    }
+                    businessSql.append("(t.team_leader_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.assign_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.accept_user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(" OR t.id IN (SELECT order_id FROM gxt_repair_order_person WHERE user_id = ")
+                            .append(currentUser.getUserId())
+                            .append(") ")
+                            .append(" OR t.create_by = '")
+                            .append(currentUser.getUserName())
+                            .append("')");
+                    continue;
+                }
+            }
+            String selfData = configService.selectConfigByKey("gxt.oder.selfData");
+            if (StringUtils.isNotEmpty(selfData) && "1".equals(selfData)) {
+                if (businessSql.length() > 0) {
+                    businessSql.append(" OR ");
+                }
+                businessSql.append("(t.team_leader_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.assign_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.accept_user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(" OR t.id IN (SELECT order_id FROM gxt_repair_order_person WHERE user_id = ")
+                        .append(currentUser.getUserId())
+                        .append(") ")
+                        .append(" OR t.create_by = '")
+                        .append(currentUser.getUserName())
+                        .append("')");
+            }
+            // 如果构建了业务特定的过滤条件,则添加到查询参数中
+            if (businessSql.length() > 0) {
+                String businessDataScopeSql = " AND (" + businessSql.toString() + ")";
+                gxtRepairOrder.getParams().put("businessDataScope", businessDataScopeSql);
+            }
+        }
+        // 对于已作废(work_order_status = 'invalid')的工单,只有admin用户才能查看
+        if (!SecurityUtils.isAdmin(currentUser.getUserId())) {
+            String invalidFilterSql = " AND (t.work_order_status != 'invalid')";
+            if (gxtRepairOrder.getParams().get("businessDataScope") != null) {
+                String existingSql = gxtRepairOrder.getParams().get("businessDataScope").toString();
+                gxtRepairOrder.getParams().put("businessDataScope", existingSql + invalidFilterSql);
+            } else {
+                gxtRepairOrder.getParams().put("businessDataScope", invalidFilterSql);
+            }
+        }
+    }
+
     @Override
     public List<GxtRepairOrder> getRepairOrderByMonth(String maintenanceType, Long pid, String monthPeriod) {
         GxtRepairOrder repairOrder = new GxtRepairOrder();
         repairOrder.setMaintenanceType(maintenanceType);
         repairOrder.setPcsStationPid(pid);
         repairOrder.setMonthPeriod(monthPeriod);
+        addBusinessDataScopeFilter(repairOrder);
         return gxtRepairOrderMapper.selectGxtRepairOrderListByMonth(repairOrder);
     }
 

+ 1 - 1
ygtx-gxt/src/main/resources/mapper/gxt/GxtMonthFanInspectionMapper.xml

@@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="deptId != null "> and pcs_station_pid = #{deptId}</if>
             <if test="monthPeriod != null  and monthPeriod != ''"> and DATE_FORMAT( create_time, '%Y-%m' ) = #{monthPeriod}</if>
-            AND inspection_type IS NOT NULL
+            AND inspection_type IS NOT NULL AND work_order_status != 'invalid'
         </where>
         GROUP BY
         model,

+ 1 - 1
ygtx-gxt/src/main/resources/mapper/gxt/GxtMonthRepairProjectMapper.xml

@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="deptId != null "> and pcs_station_pid = #{deptId}</if>
             <if test="monthPeriod != null  and monthPeriod != ''"> and DATE_FORMAT( occur_time, '%Y-%m' ) = #{monthPeriod}</if>
-            AND maintenance_type IS NOT NULL
+            AND maintenance_type IS NOT NULL AND work_order_status != 'invalid'
         </where>
         GROUP BY
         maintenance_type

+ 3 - 0
ygtx-gxt/src/main/resources/mapper/gxt/GxtRepairOrderMapper.xml

@@ -252,6 +252,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="pcsStationPid != null "> and pcs_station_pid = #{pcsStationPid}</if>
             <if test="maintenanceType != null and maintenanceType != ''"> and maintenance_type = #{maintenanceType}</if>
             <if test="monthPeriod != null"> and DATE_FORMAT(occur_time, '%Y-%m') = #{monthPeriod}</if>
+            <if test="params.businessDataScope != null and params.businessDataScope != ''">
+                ${params.businessDataScope}
+            </if>
         </where>
         order by t.occur_time desc
     </select>

+ 80 - 0
ygtx-gxt/src/main/resources/mapper/gxt/GxtWorkOrderMapper.xml

@@ -83,6 +83,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="suspendExplain"    column="suspend_explain"    />
         <result property="scoreReturnReason"    column="score_return_reason"    />
         <result property="leader"    column="leader"    />
+        <result property="runningDays"    column="running_days" />
+        <result property="stopDays"    column="stop_days" />
+        <result property="deptName"    column="dept_name" />
     </resultMap>
 
     <resultMap type="GxtOrderData" id="GxtOrderDataResult">
@@ -201,6 +204,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="inspectionType != null and inspectionType != ''"> and inspection_type = #{inspectionType}</if>
             <if test="pcsStationPid != null"> and pcs_station_pid = #{pcsStationPid}</if>
             <if test="monthPeriod != null"> and DATE_FORMAT(t.create_time, '%Y-%m') = #{monthPeriod}</if>
+            <if test="params.businessDataScope != null and params.businessDataScope != ''">
+                ${params.businessDataScope}
+            </if>
         </where>
         order by t.create_time desc
     </select>
@@ -907,4 +913,78 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LIMIT #{limit}
         </if>
     </select>
+    
+    <select id="selectGxtWorkOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
+        SELECT
+            t.pcs_device_name,
+            t.model,
+            t.work_order_project_no,
+            t.restart_time,
+            t.pause_time,
+            t.pcs_station_pid,
+            1 AS order_type,
+            t.pcs_device_id,t.gxt_center,t.pcs_station_name,d.dept_name,
+            DATEDIFF( t.restart_time, t.pause_time ) AS stop_days,
+            DATEDIFF( NOW(), t.restart_time ) AS running_days
+        FROM
+            gxt_work_order t
+            INNER JOIN ( 
+                SELECT 
+                    pcs_device_id, 
+                    MAX( pause_time ) AS latest_pause_time 
+                FROM 
+                    gxt_work_order 
+                WHERE 
+                    pause_time IS NOT NULL AND restart_time IS NOT NULL 
+                GROUP BY 
+                    pcs_device_id 
+            ) latest ON t.pcs_device_id = latest.pcs_device_id
+            AND t.pause_time = latest.latest_pause_time
+            LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
+        WHERE
+            t.pause_time IS NOT NULL
+            AND t.restart_time IS NOT NULL
+        <if test="deptName != null  and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
+        <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
+        <if test="params.businessDataScope != null and params.businessDataScope != ''">
+            ${params.businessDataScope}
+        </if>
+    </select>
+
+    <select id="selectGxtRepairOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
+        SELECT
+        t.pcs_device_name,
+        t.model,
+        t.work_order_project_no,
+        t.restart_time,
+        t.pcs_station_pid,
+        t.occur_time AS pause_time,
+        2 AS order_type,
+        t.pcs_device_id,t.gxt_center,t.pcs_station_name,d.dept_name,
+        DATEDIFF( t.restart_time, t.occur_time ) AS stop_days,
+        DATEDIFF( NOW(), t.restart_time ) AS running_days
+        FROM
+        gxt_repair_order t
+        INNER JOIN (
+        SELECT
+        pcs_device_id,
+        MAX( occur_time ) AS latest_pause_time
+        FROM
+        gxt_repair_order
+        WHERE
+        occur_time IS NOT NULL AND restart_time IS NOT NULL
+        GROUP BY
+        pcs_device_id
+        ) latest ON t.pcs_device_id = latest.pcs_device_id
+        AND t.occur_time = latest.latest_pause_time
+        LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
+        WHERE
+        t.occur_time IS NOT NULL
+        AND t.restart_time IS NOT NULL
+        <if test="deptName != null  and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
+        <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
+        <if test="params.businessDataScope != null and params.businessDataScope != ''">
+            ${params.businessDataScope}
+        </if>
+    </select>
 </mapper>

+ 29 - 1
ygtx-ui/src/views/gxt/monthScore/index.vue

@@ -161,6 +161,15 @@
     <el-card v-if="!isList" class="card-form" style="margin-bottom: 20px;" shadow="hover">
       <div slot="header" class="clearfix">
         <span style="font-weight: bold;">组员考核得分</span>
+        <el-input 
+          v-model="userFilterText" 
+          placeholder="请输入组员姓名" 
+          style="width: 200px; float: right; margin-top: 5px; margin-left: 10px;" 
+          @keyup.enter="filterUsersByName">
+          <template #suffix>
+            <i class="el-input__icon el-icon-search" @click="filterUsersByName"></i>
+          </template>
+        </el-input>
       </div>
       <div class="form-content" style="margin-top: 20px;">
         <!-- 组员考核得分表格 -->
@@ -251,6 +260,9 @@ export default {
       userScoreList: [],
       workOrderList: [],
       repairOrderList: [],
+      // 用户筛选相关
+      userFilterText: '',
+      originalUserScoreList: [],
       total:0,
       queryParams: {
         status: null,
@@ -385,6 +397,7 @@ export default {
       
       getScoreSummary(monthPeriod, rtType, deptParam).then(response => {
         if (response.code === 200 && response.monthScore) {
+          this.userFilterText = '';
           const monthScoreGet = response.monthScore;
           this.monthScore = monthScoreGet;
           if(this.monthScore.status==4) {
@@ -446,8 +459,9 @@ export default {
           
           // 设置组员考核得分数据
           if (monthScoreGet.userScores) {
-            console.log(monthScoreGet.userScores);
             this.userScoreList = monthScoreGet.userScores;
+            // 保存原始数据用于筛选
+            this.originalUserScoreList = [...monthScoreGet.userScores];
           }
         } else {
           console.error('获取月度工分汇总数据失败:', response.msg);
@@ -639,6 +653,20 @@ export default {
         path: '/workOrder/repairOrder'
       });
     },
+    
+    // 根据姓名筛选用户
+    filterUsersByName() {
+      if (!this.userFilterText.trim()) {
+        // 如果输入为空,则显示所有用户
+        this.userScoreList = [...this.originalUserScoreList];
+      } else {
+        // 根据输入的姓名筛选用户
+        const filterText = this.userFilterText.toLowerCase().trim();
+        this.userScoreList = this.originalUserScoreList.filter(user => 
+          user.nickName.toLowerCase().includes(filterText)
+        );
+      }
+    },
   }
 }
 </script>

+ 30 - 1
ygtx-ui/src/views/gxt/monthScore/info.vue

@@ -97,6 +97,15 @@
     <el-card class="card-form" shadow="hover">
       <div slot="header" class="clearfix">
         <span style="font-weight: bold;">组员考核得分</span>
+        <el-input 
+          v-model="userFilterText" 
+          placeholder="请输入组员姓名" 
+          style="width: 200px; float: right; margin-top: 5px; margin-left: 10px;" 
+          @keyup.enter="filterUsersByName">
+          <template #suffix>
+            <i class="el-input__icon el-icon-search" @click="filterUsersByName"></i>
+          </template>
+        </el-input>
       </div>
       <div class="form-content" style="margin-top: 20px;">
         <!-- 组员考核得分表格 -->
@@ -189,7 +198,10 @@ export default {
       // 组员考核得分数据
       userScoreList: [],
       workOrderList: [],
-      repairOrderList: []
+      repairOrderList: [],
+      // 用户筛选相关
+      userFilterText: '',
+      originalUserScoreList: []
     }
   },
   created() {
@@ -272,6 +284,7 @@ export default {
       // 原有逻辑
       getScoreSummary(monthPeriod, rtType, deptParam).then(response => {
         if (response.code === 200 && response.monthScore) {
+          this.userFilterText = '';
           const monthScoreGet = response.monthScore;
           this.monthScore = monthScoreGet;
           if(this.monthScore.status==4) {
@@ -334,6 +347,8 @@ export default {
           // 设置组员考核得分数据
           if (monthScoreGet.userScores) {
             this.userScoreList = monthScoreGet.userScores;
+            // 保存原始数据用于筛选
+            this.originalUserScoreList = [...monthScoreGet.userScores];
           }
           this.checkPermissions();
         } else {
@@ -511,6 +526,20 @@ export default {
         path: '/workOrder/repairOrder'
       });
     },
+    
+    // 根据姓名筛选用户
+    filterUsersByName() {
+      if (!this.userFilterText.trim()) {
+        // 如果输入为空,则显示所有用户
+        this.userScoreList = [...this.originalUserScoreList];
+      } else {
+        // 根据输入的姓名筛选用户
+        const filterText = this.userFilterText.toLowerCase().trim();
+        this.userScoreList = this.originalUserScoreList.filter(user => 
+          user.nickName.toLowerCase().includes(filterText)
+        );
+      }
+    },
   }
 }
 </script>