Bladeren bron

1.修复同步的老OA资产订单看不到产品号的问题
2.新增按照用户所在部门查询大中型评估人员提成申报列表接口与导出接口
3.大中型-项目部绩效时效不再分金融和非金融,项目部绩效新增报价准确性考核指标,评估人员效率值表-接单数只要参与了项目也算,统计时间以勘察定价时间为准,错误类型统计报表添加数据权限区分

GouGengquan 6 maanden geleden
bovenliggende
commit
48a87bfb90

+ 19 - 0
biz-base/src/main/java/com/dayou/controller/CommissionDeclareController.java

@@ -13,8 +13,10 @@ import com.dayou.service.ICommissionDeclareService;
 import com.dayou.common.RestResponse;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.List;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 /**
@@ -48,6 +50,23 @@ public class CommissionDeclareController extends BaseController {
         return RestResponse.data(pages);
     }
 
+    /**
+     * 根据部门id查询大中型提成申报信息
+     */
+    @GetMapping("/major/evaluate/byDepartment")
+    public RestResponse<Page<CommissionDeclareVO>> majorEvaluateDeclarePageByDepartment(CommissionDeclareVO commissionDeclare, Page page){
+        Page<CommissionDeclareVO> pages=commissionDeclareService.majorEvaluateDeclarePageByDepartment(page,commissionDeclare);
+        return RestResponse.data(pages);
+    }
+
+    /**
+     * 根据部门id查询大中型提成申报信息导出
+     */
+    @GetMapping("/major/evaluate/byDepartment/export")
+    public void majorEvaluateDeclarePageByDepartmentExport(CommissionDeclareVO commissionDeclare, HttpServletResponse response) throws IOException {
+        List<CommissionDeclareVO> result = commissionDeclareService.majorEvaluateDeclarePageByDepartmentExport(commissionDeclare);
+        exportPlus(response,"评估人员申报信息(部门)",result, CommissionDeclareVO.class);
+    }
 
     /**
      * 大中型提成申报

+ 17 - 0
dao/src/main/java/com/dayou/mapper/CommissionDeclareMapper.java

@@ -24,6 +24,23 @@ public interface CommissionDeclareMapper extends CustomBaseMapper<CommissionDecl
 
     Page<CommissionDeclareVO> majorEvaluateDeclarePage(Page page, @Param("declare")CommissionDeclareVO commissionDeclare, @Param("evaluateUserId")Long currentEvaluateUserId);
 
+    /**
+     * 根据部门id查询大中型提成申报信息
+     * @param page
+     * @param commissionDeclare
+     * @param departmentId
+     * @return
+     */
+    Page<CommissionDeclareVO> majorEvaluateDeclarePageByDepartment(Page page, @Param("declare")CommissionDeclareVO commissionDeclare, @Param("departmentId")Long departmentId);
+
+    /**
+     * 根据部门id查询大中型提成申报信息导出excel
+     * @param commissionDeclare
+     * @param departmentId
+     * @return
+     */
+    List<CommissionDeclareVO> majorEvaluateDeclarePageByDepartmentExport(@Param("declare")CommissionDeclareVO commissionDeclare, @Param("departmentId")Long departmentId);
+
     CommissionDeclareVO detail(@Param("id") Long id);
 
     Page<CommissionDeclareTodoCheckVO> todoCheckPage(Page page, @Param("checkVO")CommissionDeclareTodoCheckVO checkVO);

+ 1 - 1
dao/src/main/java/com/dayou/mapper/MajorStatisticalStatementMapper.java

@@ -50,7 +50,7 @@ public interface MajorStatisticalStatementMapper {
      * @param dto 查询dto
      * @return List<MajorErrorTypeCountVO>
      */
-    List<MajorErrorTypeCountVO> getMajorErrorTypeCountVO(@Param("dto") MajorStatisticalSelectDTO dto);
+    List<MajorErrorTypeCountVO> getMajorErrorTypeCountVO(@Param("dto") MajorStatisticalSelectDTO dto, @Param("self") Boolean self, @Param("dep") Boolean dep);
 
     /**
      * 查询错误详情列表

+ 4 - 2
dao/src/main/resources/mapper/AssetsMapper.xml

@@ -206,7 +206,8 @@
         assets.order_id,
         assets_business_gener,
         allot_type,
-        (SELECT production_no FROM assets_production WHERE assets_production.production_no = nodeInfo.business_sub_id) AS statementNo,
+        # 2025年1月1日之前下的订单都是老OA系统订单,查询方式不一样
+        (SELECT production_no FROM assets_production WHERE IF(assets.created &lt; '2025-01-01', assets_production.business_id = assets.id AND assets_production.production_type = 'STATEMENT',assets_production.production_no = nodeInfo.business_sub_id)) AS statementNo,
         (SELECT production_type FROM assets_production WHERE assets_production.production_no = nodeInfo.business_sub_id) AS productionType,
         reportInfo.production_no AS reportNo,
         reportInfo.repertory_state AS reportRepertoryState,
@@ -269,7 +270,8 @@
         AND nodeInstance.business_type = 'ASSET_BUSINESS'
         ) AS nodeInfo ON nodeInfo.businessId = assets.id
         LEFT JOIN production_fund AS pFund ON pFund.order_fund_id = fund.id AND pFund.production_no = nodeInfo.business_min_id
-        LEFT JOIN(SELECT production_no,repertory_state,production_type,delivery,assets_name FROM assets_production) AS reportInfo ON reportInfo.production_no = nodeInfo.business_min_id
+        # 2025年1月1日之前下的订单都是老OA系统订单,查询方式不一样
+        LEFT JOIN(SELECT business_id, production_no,repertory_state,production_type,delivery,assets_name FROM assets_production) AS reportInfo ON IF(assets.created &lt; '2025-01-01', reportInfo.business_id = assets.id AND reportInfo.production_type != 'STATEMENT',reportInfo.production_no = nodeInfo.business_min_id)
         WHERE assets.deleted = 0
         AND assets.client_manager_id = #{assetsSelectDTO.clientManagerId}
         #送达状态查询

+ 104 - 7
dao/src/main/resources/mapper/CommissionDeclareMapper.xml

@@ -128,11 +128,11 @@
         select
         (@i := @i + 1) AS id,bus.*,dd.name as commissionType from (SELECT
         IFNULL(cd.id,(SELECT id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
-        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id =#{evaluateUserId}) ) cId,
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) cId,
         IFNULL(cd.commission_rate_id,(SELECT commission_rate_id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
-        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id = #{evaluateUserId}) ) commission_rate_id,
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) commission_rate_id,
         IFNULL(cd.declare_result,(SELECT declare_result from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
-        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id = #{evaluateUserId}) ) declare_result,
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) declare_result,
         major.*
         FROM
         (
@@ -154,7 +154,8 @@
         mp.NAME,
         mp.report_no ,
         mp.created,
-        (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production
+        (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production,
+        m.principal_id
         FROM (SELECT @i := 0) AS sort,
         major m
         LEFT JOIN ( SELECT id, NAME, major_id, report_no,created,production FROM major_production WHERE deleted = 0 ) mp ON m.id = mp.major_id
@@ -164,13 +165,13 @@
         LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
         WHERE
         m.deleted = 0
-        AND m.principal_id = #{evaluateUserId}
         ) major
         LEFT JOIN ( SELECT id, ifnull( production_id, business_id ) AS xId, commission_rate_id,declare_result FROM commission_declare
-      WHERE deleted = 0 and declare_user_id = #{evaluateUserId}
+        WHERE deleted = 0
         AND business_type='COMMISSION_DECLARE_MAJOR_EVALUATE'
-      ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
+        ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
         bus.commission_rate_id = bcr.id left join dict_data dd on dd.id = bcr.business_cate_id
+        LEFT JOIN (SELECT DISTINCT department.id, department.name, user_post.user_id FROM user_post,post,department WHERE user_post.post_id = post.id AND post.department_id = department.id AND department.`name` IN ('评估一部','评估二部','评估三部')) AS department ON department.user_id = principal_id
         <where>
             <if test="declare!=null and declare.orderId!=null and declare.orderId!=''">
                 and bus.order_id like concat ('%',#{declare.orderId},'%')
@@ -206,6 +207,102 @@
         order by bus.created DESC ,bus.orderCreated DESC
     </select>
 
+    <sql id="majorEvaluateDeclarePageByDepartmentSql">
+        select
+        (@i := @i + 1) AS id,bus.*,dd.name as commissionType from (SELECT
+        IFNULL(cd.id,(SELECT id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) cId,
+        IFNULL(cd.commission_rate_id,(SELECT commission_rate_id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) commission_rate_id,
+        IFNULL(cd.declare_result,(SELECT declare_result from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
+        AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) declare_result,
+        major.*,
+        cd.created AS cdCreated
+        FROM
+        (
+        SELECT
+        m.id AS businessId,
+        mp.id AS productionId,
+        ifnull( mp.id, m.id ) AS mId,
+        m.NAME AS orderName,
+        m.order_id,
+        m.business_object_type,
+        m.bailor_contact_name,
+        m.bailor_contact_tel,
+        m.bailor,
+        m.created AS orderCreated,
+        u.NAME AS clientManager,
+        u1.NAME AS principal,
+        cc1.NAME AS clienteleName,
+        cc2.NAME AS clienteleSubName,
+        mp.NAME,
+        mp.report_no ,
+        mp.created,
+        (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production,
+        m.principal_id
+        FROM (SELECT @i := 0) AS sort,
+        major m
+        LEFT JOIN ( SELECT id, NAME, major_id, report_no,created,production FROM major_production WHERE deleted = 0 ) mp ON m.id = mp.major_id
+        LEFT JOIN user u ON u.id = m.client_manager_id
+        LEFT JOIN user u1 ON u1.id = m.principal_id
+        LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
+        LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
+        WHERE
+        m.deleted = 0
+        ) major
+        LEFT JOIN ( SELECT id, ifnull( production_id, business_id ) AS xId, commission_rate_id,declare_result,created FROM commission_declare
+        WHERE deleted = 0
+        AND business_type='COMMISSION_DECLARE_MAJOR_EVALUATE'
+        ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
+        bus.commission_rate_id = bcr.id left join dict_data dd on dd.id = bcr.business_cate_id
+        LEFT JOIN (SELECT DISTINCT department.id, department.name, user_post.user_id FROM user_post,post,department WHERE user_post.post_id = post.id AND post.department_id = department.id AND department.`name` IN ('评估一部','评估二部','评估三部')) AS department ON department.user_id = principal_id
+        WHERE department.id = #{departmentId}
+        <if test="declare != null and declare.startTime != null and declare.endTime!= null">
+            AND cdCreated BETWEEN #{declare.startTime} AND #{declare.endTime}
+        </if>
+        <if test="declare!=null and declare.orderId!=null and declare.orderId!=''">
+            and bus.order_id like concat ('%',#{declare.orderId},'%')
+        </if>
+        <if test="declare!=null and declare.name!=null and declare.name!=''">
+            and (bus.orderName like concat ('%',#{declare.name},'%') or bus.name like concat ('%',#{declare.name},'%') )
+        </if>
+        <if test="declare!=null and declare.reportNo!=null and declare.reportNo!=''">
+            and bus.report_no like concat ('%',#{declare.reportNo},'%')
+        </if>
+        <if test="declare!=null and declare.commissionRateId!=null ">
+            and bus.commission_rate_id = #{declare.commissionRateId}
+        </if>
+        <if test="declare!=null and declare.declareType!=null and declare.declareType==true">
+            and bus.productionId is not null
+        </if>
+        <if test="declare!=null and declare.declareType!=null and declare.declareType==false">
+            and bus.productionId is null
+        </if>
+        <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='待申报'">
+            and bus.declare_result is null
+        </if>
+        <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核中'">
+            and bus.declare_result = #{declare.declareResult}
+        </if>
+        <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核通过'">
+            and bus.declare_result = #{declare.declareResult}
+        </if>
+        <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核拒绝'">
+            and bus.declare_result = #{declare.declareResult}
+        </if>
+        order by bus.created DESC ,bus.orderCreated DESC
+    </sql>
+
+    <!--根据部门id查询大中型提成申报信息-->
+    <select id="majorEvaluateDeclarePageByDepartment" resultType="com.dayou.vo.CommissionDeclareVO">
+        <include refid="majorEvaluateDeclarePageByDepartmentSql" />
+    </select>
+
+    <!--根据部门id查询大中型提成申报信息导出excel-->
+    <select id="majorEvaluateDeclarePageByDepartmentExport" resultType="com.dayou.vo.CommissionDeclareVO">
+        <include refid="majorEvaluateDeclarePageByDepartmentSql" />
+    </select>
+
     <select id="detail" parameterType="java.lang.Long" resultType="com.dayou.vo.CommissionDeclareVO">
         SELECT
             cd.id,

File diff suppressed because it is too large
+ 289 - 68
dao/src/main/resources/mapper/MajorStatisticalStatementMapper.xml


+ 15 - 0
domain/src/main/java/com/dayou/dto/MajorStatisticalSelectDTO.java

@@ -49,6 +49,21 @@ public class MajorStatisticalSelectDTO {
     private Long memberId;
 
     /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 岗位id
+     */
+    private Long postId;
+
+    /**
+     * 审核轮次类型(dep:只统计初审,com:不统计初审)
+     */
+    private String checkType;
+
+    /**
      * 接单部门id
      */
     private Long departmentId;

+ 29 - 0
domain/src/main/java/com/dayou/vo/CommissionDeclareVO.java

@@ -1,5 +1,7 @@
 package com.dayou.vo;
 
+import com.dayou.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.util.Date;
@@ -37,63 +39,78 @@ public class CommissionDeclareVO {
     /**
      * 订单号
      */
+    @Excel(name = "订单号")
     private String orderId;
 
     /**
      * 订单名称
      */
+    @Excel(name = "项目编号")
     private String orderName;
     /**
      *项目名称
      */
+    @Excel(name = "项目名称")
     private String name;
     /**
      *报告号
      */
+    @Excel(name = "报告号")
     private String reportNo;
     /**
      *评估对象类别
      */
+    @Excel(name = "评估对象类别")
     private String businessObjectType;
     /**
      *委托人
      */
+    @Excel(name = "委托人")
     private String bailor;
     /**
      *委托联系人
      */
+    @Excel(name = "委托联系人")
     private String bailorContactName;
     /**
      *委托人电话
      */
+    @Excel(name = "委托人电话")
     private String bailorContactTel;
     /**
      *客户名称
      */
+    @Excel(name = "客户名称")
     private String clienteleName;
     /**
      *业务来源
      */
+    @Excel(name = "业务来源")
     private String clienteleSubName;
     /**
      *负责人
      */
+    @Excel(name = "负责人")
     private String principal;
     /**
      *客户经理
      */
+    @Excel(name = "客户经理")
     private String clientManager;
     /**
      *下单时间
      */
+    @Excel(name = "下单时间")
     private Date orderCreated;
     /**
      *提成类型
      */
+    @Excel(name = "提成类型")
     private String commissionType;
     /**
      *审核状态
      */
+    @Excel(name = "审核状态")
     private String declareResult;
 
     private Long commissionRateId;
@@ -132,4 +149,16 @@ public class CommissionDeclareVO {
      */
     private String production;
 
+    /**
+     * 筛选开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+
+    /**
+     * 筛选结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+
 }

+ 34 - 10
domain/src/main/java/com/dayou/vo/MajorDepPerformanceOverviewVO.java

@@ -41,29 +41,41 @@ public class MajorDepPerformanceOverviewVO {
     @Excel(name = "接件数计分")
     private Integer orderVolumeScore;
 
-    /**
+/*    *//**
      * 报价效率(金融)
-     */
+     *//*
     @Excel(name = "报价效率(金融)")
     private Double financialQuoteProcessingTime;
 
-    /**
+    *//**
      * 报价效率计分(金融)
-     */
+     *//*
     @Excel(name = "报价效率计分(金融)")
-    private Integer financialQuoteProcessingTimeScore;
+    private Integer financialQuoteProcessingTimeScore;*/
 
-    /**
+/*    *//**
      * 报价效率(非金融)
-     */
+     *//*
     @Excel(name = "报价效率(非金融)")
     private Double unFinancialQuoteProcessingTime;
 
-    /**
+    *//**
      * 报价效率计分(非金融)
-     */
+     *//*
     @Excel(name = "报价效率计分(非金融)")
-    private Integer unFinancialQuoteProcessingTimeScore;
+    private Integer unFinancialQuoteProcessingTimeScore;*/
+
+    /**
+     * 报价效率
+     */
+    @Excel(name = "报价效率")
+    private Double quoteProcessingTime;
+
+    /**
+     * 报价效率计分
+     */
+    @Excel(name = "报价效率计分")
+    private Integer quoteProcessingTimeScore;
 
     /**
      * 复审一般错误数量
@@ -90,6 +102,18 @@ public class MajorDepPerformanceOverviewVO {
     private Integer reCheckTotalScore;
 
     /**
+     * 报价准确度
+     */
+    @Excel(name = "报价准确度")
+    private Double quotationAccuracy;
+
+    /**
+     * 报价准确度计分
+     */
+    @Excel(name = "报价准确度计分")
+    private Integer quotationAccuracyScore;
+
+    /**
      * 时点累计分值
      */
     @Excel(name = "时点累计分值")

+ 15 - 0
service/src/main/java/com/dayou/service/ICommissionDeclareService.java

@@ -30,6 +30,21 @@ public interface ICommissionDeclareService extends IService<CommissionDeclare> {
 
     Page<CommissionDeclareVO> majorEvaluateDeclarePage(Page page, CommissionDeclareVO commissionDeclare);
 
+    /**
+     * 根据部门id查询大中型提成申报信息
+     * @param page
+     * @param commissionDeclare
+     * @return
+     */
+    Page<CommissionDeclareVO> majorEvaluateDeclarePageByDepartment(Page page, CommissionDeclareVO commissionDeclare);
+
+    /**
+     * 根据部门id查询大中型提成申报信息导出excel
+     * @param commissionDeclare
+     * @return
+     */
+    List<CommissionDeclareVO> majorEvaluateDeclarePageByDepartmentExport(CommissionDeclareVO commissionDeclare);
+
     Long commissionDeclare(CommissionDeclareDTO declareDTO);
 
     CommissionDeclareDetailVO detail(Long id);

+ 35 - 0
service/src/main/java/com/dayou/service/impl/CommissionDeclareServiceImpl.java

@@ -4,8 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.dayou.bo.SimpleParentModel;
 import com.dayou.common.BaseEntity;
 import com.dayou.dto.CommissionDeclareDTO;
+import com.dayou.dto.SimpleDepartmentModel;
+import com.dayou.dto.SimplePostModel;
 import com.dayou.dto.UserShareRate;
 import com.dayou.entity.*;
 import com.dayou.enums.FinanceInvoiceState;
@@ -31,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import static com.dayou.enums.MainBusinessEnum.*;
@@ -104,6 +108,37 @@ public class CommissionDeclareServiceImpl extends ServiceImpl<CommissionDeclareM
         return commissionDeclareMapper.majorEvaluateDeclarePage(page,commissionDeclare,currentEvaluateUserId);
     }
 
+    /**
+     * 根据部门id查询大中型提成申报信息
+     * @param page
+     * @param commissionDeclare
+     * @return
+     */
+    @Override
+    public Page<CommissionDeclareVO> majorEvaluateDeclarePageByDepartment(Page page, CommissionDeclareVO commissionDeclare) {
+        List<SimpleParentModel> depList = LoginContext.getLoginCacheUserBO().getDepartmentList();
+        Optional<Long> dep = depList.stream()
+                .filter(obj -> "评估一部".equals(obj.getName()) || "评估二部".equals(obj.getName()) || "评估三部".equals(obj.getName()))
+                .map(SimpleParentModel::getId)
+                .findFirst();
+        return commissionDeclareMapper.majorEvaluateDeclarePageByDepartment(page, commissionDeclare, dep.get());
+    }
+
+    /**
+     * 根据部门id查询大中型提成申报信息导出excel
+     * @param commissionDeclare
+     * @return
+     */
+    @Override
+    public List<CommissionDeclareVO> majorEvaluateDeclarePageByDepartmentExport(CommissionDeclareVO commissionDeclare) {
+        List<SimpleParentModel> depList = LoginContext.getLoginCacheUserBO().getDepartmentList();
+        Optional<Long> dep = depList.stream()
+                .filter(obj -> "评估一部".equals(obj.getName()) || "评估二部".equals(obj.getName()) || "评估三部".equals(obj.getName()))
+                .map(SimpleParentModel::getId)
+                .findFirst();
+        return commissionDeclareMapper.majorEvaluateDeclarePageByDepartmentExport(commissionDeclare, dep.get());
+    }
+
     @Override
     @SendMessage(messageType = MAJOR_DECLARE_REMIND)
     @Transactional

+ 44 - 20
service/src/main/java/com/dayou/service/impl/MajorStatisticalStatementServiceImpl.java

@@ -5,10 +5,15 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dayou.bo.SimpleParentModel;
 import com.dayou.dto.MajorStatisticalSelectDTO;
+import com.dayou.dto.SimplePostModel;
+import com.dayou.entity.Post;
 import com.dayou.entity.User;
 import com.dayou.mapper.DepartmentMapper;
 import com.dayou.mapper.MajorStatisticalStatementMapper;
+import com.dayou.mapper.PostMapper;
+import com.dayou.mapper.UserPostMapper;
 import com.dayou.service.IUserService;
 import com.dayou.service.IMajorStatisticalStatementService;
 import com.dayou.utils.LoginContext;
@@ -19,6 +24,7 @@ import org.springframework.stereotype.Service;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Optional;
 
 @Service
 public class MajorStatisticalStatementServiceImpl implements IMajorStatisticalStatementService {
@@ -30,6 +36,9 @@ public class MajorStatisticalStatementServiceImpl implements IMajorStatisticalSt
     private DepartmentMapper departmentMapper;
 
     @Autowired
+    private UserPostMapper userPostMapper;
+
+    @Autowired
     private MajorStatisticalStatementMapper majorStatisticalStatementMapper;
 
     /**
@@ -95,7 +104,22 @@ public class MajorStatisticalStatementServiceImpl implements IMajorStatisticalSt
      */
     @Override
     public List<MajorErrorTypeCountVO> getMajorErrorTypeCountVO(MajorStatisticalSelectDTO dto) {
-        return majorStatisticalStatementMapper.getMajorErrorTypeCountVO(dto);
+        dto.setUserId(LoginContext.getUserId());
+        List<SimplePostModel> post = userPostMapper.getPostList(dto.getUserId());
+        // 判断当前用户是否是三审或四审人员
+        boolean verifier = post.stream()
+                .anyMatch(obj -> "三审人".equals(obj.getName()) || "复审人".equals(obj.getName()));
+        // 判断当前用户是否是评估部经理,是则获取评估部id
+        Optional<Long> dep = post.stream()
+                .filter(obj -> "评估部经理".equals(obj.getName()))
+                .map(SimplePostModel::getDepartmentId)
+                .findFirst();
+        dep.ifPresent(
+                dto::setDepartmentId
+        );
+        // 达成是审核或部门经理任一条件都不是仅查看自己
+        boolean self = !verifier && !ObjectUtil.isNotNull(dto.getDepartmentId());
+        return majorStatisticalStatementMapper.getMajorErrorTypeCountVO(dto, self, ObjectUtil.isNotNull(dto.getDepartmentId()));
     }
 
     /**
@@ -389,45 +413,45 @@ public class MajorStatisticalStatementServiceImpl implements IMajorStatisticalSt
             }
         }
 
-        // 金融报价效率进行降序排序
-        overviewVOList.sort(Comparator.comparing(MajorDepPerformanceOverviewVO::getFinancialQuoteProcessingTime, Comparator.nullsLast(Comparator.reverseOrder())));
-        // 排名赋分(第一名:10、第二名:8、第三名:7)
+        // 报价效率进行降序排序
+        overviewVOList.sort(Comparator.comparing(MajorDepPerformanceOverviewVO::getQuoteProcessingTime, Comparator.nullsLast(Comparator.reverseOrder())));
+        // 排名赋分(第一名:10、第二名:8、第三名:7)时效值越小,得分越高
         for (int i = 0; i < overviewVOList.size(); i++){
-            // 判断金融报价是否不为null
-            if (ObjectUtil.isNull(overviewVOList.get(i).getFinancialQuoteProcessingTime())){ // 将金融报价效率计分设为0
-                overviewVOList.get(i).setFinancialQuoteProcessingTimeScore(0);
+            // 判断金融报价是否不为null
+            if (ObjectUtil.isNull(overviewVOList.get(i).getQuoteProcessingTime())){ // 将金融报价效率计分设为0
+                overviewVOList.get(i).setQuoteProcessingTimeScore(0);
             }else {
-                switch (i) { // 按金融报价效率排名设定份数
+                switch (i) { // 按金融报价效率排名设定份数
                     case 0:
-                        overviewVOList.get(i).setFinancialQuoteProcessingTimeScore(10);
+                        overviewVOList.get(i).setQuoteProcessingTimeScore(7);
                         break;
                     case 1:
-                        overviewVOList.get(i).setFinancialQuoteProcessingTimeScore(8);
+                        overviewVOList.get(i).setQuoteProcessingTimeScore(8);
                         break;
                     case 2:
-                        overviewVOList.get(i).setFinancialQuoteProcessingTimeScore(7);
+                        overviewVOList.get(i).setQuoteProcessingTimeScore(10);
                         break;
                 }
             }
         }
 
-        // 非金融报价效率进行降序排序
-        overviewVOList.sort(Comparator.comparing(MajorDepPerformanceOverviewVO::getUnFinancialQuoteProcessingTime, Comparator.nullsLast(Comparator.reverseOrder())));
-        // 排名赋分(第一名:10、第二名:8、第三名:7)
+        // 报价准确度进行降序排序
+        overviewVOList.sort(Comparator.comparing(MajorDepPerformanceOverviewVO::getQuotationAccuracy, Comparator.nullsLast(Comparator.reverseOrder())));
+        // 排名赋分(第一名:10、第二名:8、第三名:7)报价准确度越接近1,得分越高
         for (int i = 0; i < overviewVOList.size(); i++){
             // 判断非金融报价是否不为null
-            if (ObjectUtil.isNull(overviewVOList.get(i).getUnFinancialQuoteProcessingTime())){ // 将非金融报价效率计分设为0
-                overviewVOList.get(i).setUnFinancialQuoteProcessingTimeScore(0);
+            if (ObjectUtil.isNull(overviewVOList.get(i).getQuotationAccuracy())){ // 将非金融报价效率计分设为0
+                overviewVOList.get(i).setQuotationAccuracyScore(0);
             }else {
                 switch (i) { // 按非金融报价效率排名设定份数
                     case 0:
-                        overviewVOList.get(i).setUnFinancialQuoteProcessingTimeScore(10);
+                        overviewVOList.get(i).setQuotationAccuracyScore(7);
                         break;
                     case 1:
-                        overviewVOList.get(i).setUnFinancialQuoteProcessingTimeScore(8);
+                        overviewVOList.get(i).setQuotationAccuracyScore(8);
                         break;
                     case 2:
-                        overviewVOList.get(i).setUnFinancialQuoteProcessingTimeScore(7);
+                        overviewVOList.get(i).setQuotationAccuracyScore(10);
                         break;
                 }
             }
@@ -436,7 +460,7 @@ public class MajorStatisticalStatementServiceImpl implements IMajorStatisticalSt
         // 计算复审扣分与最后的时间累计分值
         for (MajorDepPerformanceOverviewVO overviewVO : overviewVOList){
             overviewVO.setReCheckTotalScore(overviewVO.getReCheckNormalMistakeCount() * 3 + overviewVO.getReCheckHardMistakeCount() * 8 + overviewVO.getReCheckFatalMistakeCount() * 41);
-            overviewVO.setTimePointTotalScore(overviewVO.getOutputValueScore() + overviewVO.getOrderVolumeScore() + overviewVO.getFinancialQuoteProcessingTimeScore() + overviewVO.getUnFinancialQuoteProcessingTimeScore() - overviewVO.getReCheckTotalScore());
+            overviewVO.setTimePointTotalScore(overviewVO.getOutputValueScore() + overviewVO.getOrderVolumeScore() + overviewVO.getQuoteProcessingTimeScore() - overviewVO.getReCheckTotalScore() + overviewVO.getQuotationAccuracyScore());
         }
 
         // 重新排序部门顺序