ouyj 5 hónapja
szülő
commit
de4a8c52f6

+ 32 - 1
ygtx-gxt/src/main/java/com/ygtx/gxt/controller/GxtOrderScoreController.java

@@ -2,8 +2,10 @@ package com.ygtx.gxt.controller;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ygtx.common.utils.StringUtils;
 import com.ygtx.gxt.domain.*;
 import com.ygtx.gxt.service.IGxtOrderScoreService;
 import com.ygtx.gxt.service.IGxtRepairOrderService;
@@ -56,9 +58,38 @@ public class GxtOrderScoreController extends BaseController
         // 开启分页插件自动分页
         startPage();
         // 查询合并的工单列表
-        List<OrderScoreInfo> list = gxtOrderScoreService.selectUnionOrderList(repairOrder, workOrder);
+        List<OrderScoreInfo> list = gxtOrderScoreService.selectUnionOrderList(repairOrder, workOrder, null);
         return getDataTable(list);
     }
+    
+    /**
+     * 查询移动端工单评分列表(合并维修工单和维保工单)
+     */
+    @PreAuthorize("@ss.hasPermi('gxt:orderScore:list')")
+    @GetMapping("/mobile/list")
+    public TableDataInfo mobileList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String keyword , String scoringStatus)
+    {
+        // 开启分页插件自动分页
+        startPage();
+        // 查询合并的工单列表
+        /*if(StringUtils.isNotEmpty(scoringStatus)){
+            repairOrder.setScoringStatus(scoringStatus);
+            workOrder.setScoringStatus(scoringStatus);
+        }*/
+        List<OrderScoreInfo> list = gxtOrderScoreService.selectUnionOrderList(repairOrder, workOrder, keyword);
+        return getDataTable(list);
+    }
+
+    /**
+     * 获取工单评分统计信息
+     */
+    @PreAuthorize("@ss.hasPermi('gxt:orderScore:list')")
+    @GetMapping("/statistics")
+    public AjaxResult getStatistics(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String month)
+    {
+        Map<String, Object> statistics = gxtOrderScoreService.getOrderScoreStatistics(repairOrder, workOrder, month);
+        return AjaxResult.success(statistics);
+    }
 
     /**
      * 获取工单评分详细信息

+ 16 - 2
ygtx-gxt/src/main/java/com/ygtx/gxt/mapper/GxtOrderScoreMapper.java

@@ -6,6 +6,7 @@ import com.ygtx.gxt.domain.OrderScoreInfo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 工单评分Mapper接口
@@ -23,15 +24,28 @@ public interface GxtOrderScoreMapper {
      * @return 合并的工单列表
      */
     public List<OrderScoreInfo> selectUnionOrderList(@Param("repairOrder") GxtRepairOrder repairOrder,
-                                                     @Param("workOrder") GxtWorkOrder workOrder);
+                                                     @Param("workOrder") GxtWorkOrder workOrder, @Param("keyword") String keyword);
 
     /**
-     * 查询合并的工单列表(维修工单和维保工单)
+     * 查询移动端合并的工单列表(维修工单和维保工单)
      *
      * @param repairOrder 维修工单查询条件
      * @param workOrder 维保工单查询条件
+     * @param keyword 关键词(工单编码或风机编号)
      * @return 合并的工单列表
      */
     public List<OrderScoreInfo> selectMobileUnionOrderList(@Param("repairOrder") GxtRepairOrder repairOrder,
                                                      @Param("workOrder") GxtWorkOrder workOrder, @Param("keyword") String keyword);
+                                                     
+    /**
+     * 查询工单评分统计信息
+     *
+     * @param repairOrder 维修工单查询条件
+     * @param workOrder 维保工单查询条件
+     * @param month 月份筛选条件
+     * @return 统计信息
+     */
+    public Map<String, Object> selectOrderScoreStatistics(@Param("repairOrder") GxtRepairOrder repairOrder,
+                                                          @Param("workOrder") GxtWorkOrder workOrder,
+                                                          @Param("month") String month);
 }

+ 13 - 1
ygtx-gxt/src/main/java/com/ygtx/gxt/service/IGxtOrderScoreService.java

@@ -5,6 +5,7 @@ import com.ygtx.gxt.domain.GxtWorkOrder;
 import com.ygtx.gxt.domain.OrderScoreInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 工单评分Service接口
@@ -21,7 +22,17 @@ public interface IGxtOrderScoreService {
      * @param workOrder 维保工单查询条件
      * @return 合并的工单列表
      */
-    public List<OrderScoreInfo> selectUnionOrderList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder);
+    public List<OrderScoreInfo> selectUnionOrderList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String keyword);
+    
+    /**
+     * 获取工单评分统计信息
+     *
+     * @param repairOrder 维修工单查询条件
+     * @param workOrder 维保工单查询条件
+     * @param month 月份筛选条件
+     * @return 统计信息
+     */
+    public Map<String, Object> getOrderScoreStatistics(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String month);
     
     /**
      * 保存自评信息
@@ -63,4 +74,5 @@ public interface IGxtOrderScoreService {
      * @return 合并的工单列表
      */
     public List<OrderScoreInfo> selectMobileUnionOrderList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String keyword);
+
 }

+ 50 - 3
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtOrderScoreServiceImpl.java

@@ -16,7 +16,9 @@ import com.ygtx.framework.aspectj.DataScopeAspect;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 工单评分Service业务层处理
@@ -44,7 +46,7 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
      * @return 合并的工单列表
      */
     @Override
-    public List<OrderScoreInfo> selectUnionOrderList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder) {
+    public List<OrderScoreInfo> selectUnionOrderList(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String keyword) {
         // 添加业务特定的数据权限过滤
         addBusinessDataScopeFilter(repairOrder, workOrder);
 
@@ -59,7 +61,7 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
             }
         }
         // 查询工单列表
-        List<OrderScoreInfo> orderList = gxtOrderScoreMapper.selectUnionOrderList(repairOrder, workOrder);
+        List<OrderScoreInfo> orderList = gxtOrderScoreMapper.selectUnionOrderList(repairOrder, workOrder, keyword);
         
         // 为每个工单填充人员评分列表数据
         for (OrderScoreInfo order : orderList) {
@@ -107,6 +109,51 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
         return orderList;
     }
     
+    /**
+     * 获取工单评分统计信息
+     *
+     * @param repairOrder 维修工单查询条件
+     * @param workOrder 维保工单查询条件
+     * @param month 月份筛选条件
+     * @return 统计信息
+     */
+    @Override
+    public Map<String, Object> getOrderScoreStatistics(GxtRepairOrder repairOrder, GxtWorkOrder workOrder, String month) {
+        // 添加业务特定的数据权限过滤
+        addBusinessDataScopeFilter(repairOrder, workOrder);
+
+        // 设置创建人,用于数据权限过滤
+        if(!Constants.SUPER_ADMIN.equals(SecurityUtils.getUsername())){
+            if (repairOrder.getCreateBy() == null || repairOrder.getCreateBy().isEmpty()) {
+                repairOrder.setCreateBy(SecurityUtils.getUsername());
+            }
+
+            if (workOrder.getCreateBy() == null || workOrder.getCreateBy().isEmpty()) {
+                workOrder.setCreateBy(SecurityUtils.getUsername());
+            }
+        }
+        
+        Map<String, Object> result = new HashMap<>();
+        
+        // 获取统计信息
+        Map<String, Object> statistics = gxtOrderScoreMapper.selectOrderScoreStatistics(repairOrder, workOrder, month);
+        result.putAll(statistics);
+        
+        // 计算总工分
+        Object maintenanceScoreObj = statistics.get("maintenanceScore");
+        Object repairScoreObj = statistics.get("repairScore");
+        
+        double maintenanceScore = maintenanceScoreObj != null ? ((Number) maintenanceScoreObj).doubleValue() : 0.0;
+        double repairScore = repairScoreObj != null ? ((Number) repairScoreObj).doubleValue() : 0.0;
+        double totalScore = maintenanceScore + repairScore;
+        
+        result.put("totalScore", totalScore);
+        result.put("maintenanceScore", maintenanceScore);
+        result.put("repairScore", repairScore);
+        
+        return result;
+    }
+    
     /**
      * 保存自评信息
      * 
@@ -731,4 +778,4 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
         // 如果不是所有用户都已确认,保持当前状态不变
         return null;
     }
-}
+}

+ 56 - 2
ygtx-gxt/src/main/resources/mapper/gxt/GxtOrderScoreMapper.xml

@@ -112,6 +112,9 @@
                 update_time as update_time
             FROM gxt_repair_order t
             <where>
+                <if test="keyword != null and keyword != ''">
+                    and (work_order_project_no like concat('%', #{keyword}, '%') or pcs_device_name like concat('%', #{keyword}, '%'))
+                </if>
                 <if test="repairOrder.workOrderProjectNo != null and repairOrder.workOrderProjectNo != ''"> and work_order_project_no like concat('%', #{repairOrder.workOrderProjectNo}, '%')</if>
                 <if test="repairOrder.workOrderStatus != null and repairOrder.workOrderStatus != ''"> and work_order_status = #{repairOrder.workOrderStatus}</if>
                 <if test="repairOrder.gxtCenterId != null"> and gxt_center_id = #{repairOrder.gxtCenterId}</if>
@@ -121,7 +124,7 @@
                 <if test="repairOrder.pcsDeviceId != null"> and pcs_device_id = #{repairOrder.pcsDeviceId}</if>
                 <if test="repairOrder.pcsDeviceName != null and repairOrder.pcsDeviceName != ''"> and pcs_device_name like concat('%', #{repairOrder.pcsDeviceName}, '%')</if>
                 <if test="repairOrder.teamLeaderName != null and repairOrder.teamLeaderName != ''"> and team_leader_name like concat('%', #{repairOrder.teamLeaderName}, '%')</if>
-                <if test="repairOrder.scoringStatus != null"> and scoring_status = #{repairOrder.scoringStatus}</if>
+                <if test="repairOrder.scoringStatus != null and repairOrder.scoringStatus != ''"> and scoring_status = #{repairOrder.scoringStatus}</if>
                 <if test="repairOrder.orderType != null and repairOrder.orderType != ''"> and 1 = #{repairOrder.orderType}</if>
                 and NULLIF(scoring_status, '') IS NOT NULL
                 <!-- 业务特定数据权限过滤条件 -->
@@ -184,6 +187,9 @@
                 update_time as update_time
             FROM gxt_work_order t
             <where>
+                <if test="keyword != null and keyword != ''">
+                    and (work_order_project_no like concat('%', #{keyword}, '%') or pcs_device_name like concat('%', #{keyword}, '%'))
+                </if>
                 <if test="workOrder.workOrderProjectNo != null and workOrder.workOrderProjectNo != ''"> and work_order_project_no like concat('%', #{workOrder.workOrderProjectNo}, '%')</if>
                 <if test="workOrder.workOrderStatus != null and workOrder.workOrderStatus != ''"> and work_order_status = #{workOrder.workOrderStatus}</if>
                 <if test="workOrder.gxtCenterId != null"> and gxt_center_id = #{workOrder.gxtCenterId}</if>
@@ -193,7 +199,7 @@
                 <if test="workOrder.pcsDeviceId != null"> and pcs_device_id = #{workOrder.pcsDeviceId}</if>
                 <if test="workOrder.pcsDeviceName != null and workOrder.pcsDeviceName != ''"> and pcs_device_name like concat('%', #{workOrder.pcsDeviceName}, '%')</if>
                 <if test="workOrder.teamLeaderName != null and workOrder.teamLeaderName != ''"> and team_leader_name like concat('%', #{workOrder.teamLeaderName}, '%')</if>
-                <if test="workOrder.scoringStatus != null"> and scoring_status = #{workOrder.scoringStatus}</if>
+                <if test="workOrder.scoringStatus != null and workOrder.scoringStatus != ''"> and scoring_status = #{workOrder.scoringStatus}</if>
                 <if test="workOrder.orderType != null and workOrder.orderType != ''"> and 2 = #{workOrder.orderType}</if>
                 and NULLIF(scoring_status, '') IS NOT NULL
                 <!-- 业务特定数据权限过滤条件 -->
@@ -204,6 +210,7 @@
         ) t
         ORDER BY create_time DESC
     </select>
+
     <select id="selectMobileUnionOrderList" resultMap="OrderScoreInfoResult">
         SELECT * FROM (
         SELECT
@@ -354,4 +361,51 @@
         ) t
         ORDER BY create_time DESC
     </select>
+
+    <select id="selectOrderScoreStatistics" resultType="map">
+        SELECT 
+            COALESCE(SUM(CASE WHEN order_type = 2 THEN score ELSE 0 END), 0) AS maintenanceScore,
+            COALESCE(SUM(CASE WHEN order_type = 1 THEN score ELSE 0 END), 0) AS repairScore,
+            COUNT(CASE WHEN order_type = 2 THEN 1 END) AS maintenanceCount,
+            COUNT(CASE WHEN order_type = 1 THEN 1 END) AS repairCount
+        FROM (
+            SELECT
+                2 as order_type,
+                score as score
+            FROM gxt_work_order t
+            <where>
+                scoring_status IS NOT NULL AND scoring_status != ''
+                <if test="workOrder.scoringStatus != null and workOrder.scoringStatus != ''"> 
+                    AND scoring_status = #{workOrder.scoringStatus}
+                </if>
+                <if test="month != null and month != ''">
+                    AND DATE_FORMAT(real_end_time, '%Y-%m') = #{month}
+                </if>
+                <!-- 业务特定数据权限过滤条件 -->
+                <if test="workOrder.params.businessDataScope != null and workOrder.params.businessDataScope != ''">
+                    ${workOrder.params.businessDataScope}
+                </if>
+            </where>
+
+            UNION ALL
+
+            SELECT
+                1 as order_type,
+                score as score
+            FROM gxt_repair_order t
+            <where>
+                scoring_status IS NOT NULL AND scoring_status != ''
+                <if test="repairOrder.scoringStatus != null and repairOrder.scoringStatus != ''"> 
+                    AND scoring_status = #{repairOrder.scoringStatus}
+                </if>
+                <if test="month != null and month != ''">
+                    AND DATE_FORMAT(real_end_time, '%Y-%m') = #{month}
+                </if>
+                <!-- 业务特定数据权限过滤条件 -->
+                <if test="repairOrder.params.businessDataScope != null and repairOrder.params.businessDataScope != ''">
+                    ${repairOrder.params.businessDataScope}
+                </if>
+            </where>
+        ) t
+    </select>
 </mapper>