Bladeren bron

大中型下单限制

wucl 1 maand geleden
bovenliggende
commit
db8134fad4

+ 11 - 0
biz-base/src/main/java/com/dayou/controller/DepartmentController.java

@@ -6,6 +6,7 @@ import com.dayou.annotation.OperLog;
 import com.dayou.dto.SimpleDepartmentModel;
 import com.dayou.vo.DepartmentStatVO;
 import com.dayou.vo.DepartmentVO;
+import com.dayou.vo.MajorDepartmentVO;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -172,5 +173,15 @@ public class DepartmentController extends BaseController {
         DepartmentStatVO bo = departmentService.stat();
         return RestResponse.data(bo);
     }
+
+    /**
+     * 大中型接单部门
+     */
+    @GetMapping("/allot/major")
+    public RestResponse<List<MajorDepartmentVO>> allotMajor(){
+        List<MajorDepartmentVO> majorDepartmentVOS = departmentService.allotMajor();
+        return RestResponse.data(majorDepartmentVOS);
+    }
+
 }
 

+ 10 - 0
biz-base/src/main/java/com/dayou/controller/MajorController.java

@@ -190,5 +190,15 @@ public class MajorController extends BaseController {
         Boolean ret = majorService.updateDepartment(taskRecordDTO);
         return RestResponse.data(ret);
     }
+
+    /**
+     * 评估部经理获取部门积压单数
+     * @return
+     */
+    @GetMapping("/department/orderOverStock")
+    public RestResponse<Integer> getDepartmentOrderOverStock(){
+        Integer res = majorService.getDepartmentOrderOverStock();
+        return RestResponse.data(res);
+    }
 }
 

+ 3 - 0
dao/src/main/java/com/dayou/mapper/DepartmentMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dayou.entity.Department;
 import com.dayou.dao.CustomBaseMapper;
 import com.dayou.vo.DepartmentVO;
+import com.dayou.vo.MajorDepartmentVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -49,4 +50,6 @@ public interface DepartmentMapper extends CustomBaseMapper<Department> {
      * @return Long 下单部门id
      */
     Long getManagerDepId(@Param("managerId") Long managerId);
+
+    List<MajorDepartmentVO> allotMajor();
 }

+ 10 - 0
dao/src/main/java/com/dayou/mapper/MajorMapper.java

@@ -37,7 +37,17 @@ public interface MajorMapper extends CustomBaseMapper<Major> {
 
     Page<MajorVO> xPage(Page page, @Param("major") MajorVO major,@Param("keyword") String keyword ,@Param("currentUserId") Long currentUserId);
 
+    Page<MajorVO> pgLeaderPage(Page page, @Param("major") MajorVO major,@Param("keyword") String keyword);
+
+    Page<MajorVO> scNonFinancePage(Page page, @Param("major") MajorVO major,@Param("keyword") String keyword);
+
+    Page<MajorVO> scFinancePage(Page page, @Param("major") MajorVO major,@Param("keyword") String keyword);
+
     List<MajorSubClientDTO> findMajorSubClient();
 
     MajorVO productionDetail(@Param("id")Long id, @Param("productionNo") String productionNo,@Param("production") String production);
+
+    Integer getDepartmentOrderOverStock(@Param("departmentId") Long departmentId);
+
+
 }

+ 42 - 0
dao/src/main/resources/mapper/DepartmentMapper.xml

@@ -96,4 +96,46 @@
           AND user.id = #{managerId}
         LIMIT 1
     </select>
+
+    <select id="allotMajor" resultType="com.dayou.vo.MajorDepartmentVO">
+        SELECT
+            d.id,
+            d.NAME,
+            o.orderOverStock
+        FROM
+            (
+                SELECT
+                    id,
+                    NAME
+                FROM
+                    department
+                WHERE
+                    deleted = 0
+                  AND NAME IN ( '评估一部', '评估二部', '评估三部' )) d
+                LEFT JOIN (
+                SELECT
+                    department_id,
+                    count(*) AS orderOverStock
+                FROM
+                    major
+                WHERE
+                    id IN (
+                        SELECT
+                            business_id
+                        FROM
+                            work_flow_node_instance
+                        WHERE
+                            flow_id = 6
+                          AND business_type = 'MAJOR_BUSINESS'
+                          AND deleted = 0
+                          AND state = 'PENDING'
+                          AND node_id IN ( 55, 56, 57, 58, 59 ))
+                  AND deleted = 0
+                  AND allot_type = '轮单'
+                GROUP BY
+                    department_id
+            ) o ON d.id = o.department_id
+        ORDER BY
+            d.id
+    </select>
 </mapper>

+ 249 - 82
dao/src/main/resources/mapper/MajorMapper.xml

@@ -394,80 +394,83 @@
             ( SELECT count(*) FROM major_production WHERE deleted = 0 AND repertory_state = 0 ) AS inWarehouseCount
     </select>
 
-    <select id="xPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
-        SELECT
-        wfni.currentNodeId AS id,
-        wfni.nodeName,
-        wfni.productionName,
-        wfni.business_sub_id AS statementNo,
-        wfni.business_min_id AS reportNo,
-        m.id AS majorId,
-        m.created,
-        m.NAME,
-        m.order_id,
-        m.financial,
-        m.allot_type,
-        m.client_manager_id,
-        u.NAME AS clientManager,
-        m.principal_id,
-        u1.NAME AS principal,
-        m.department_id,
-        d.NAME AS department,
-        m.business_object_type,
-        m.clientele_id,
-        m.clientele_contact_id,
-        m.clientele_id AS clientele,
-        m.clientele_contact_id AS clienteleContact,
-        cc1.NAME AS cClienteleName,
-        cc2.NAME AS cClienteleSubName,
-        cl1.NAME AS cClienteleContactName,
-        cl1.mobile AS cMobile,
-        wfni.client_name,
-        wfni.client_tel,
-        wfni.evaluate_amount,
-        wfni.OWNER,
-        wfni.HANDLER,
-        wfni.nodeCode,
-        wfni.currentNodeId
-        FROM
-        major m
-        LEFT JOIN user u ON u.id = m.client_manager_id
-        LEFT JOIN user u1 ON u1.id = m.principal_id
-        LEFT JOIN department d ON d.id = m.department_id
-        INNER JOIN (
+    <sql id="majorPageSql">
         SELECT
-        wf.id AS currentNodeId,
-        wf.node_id,
-        wf.business_id,
-        wf.business_sub_id,
-        wf.business_min_id,
-        wf.state,
-        wn.NAME AS nodeName,
-        mp.NAME AS productionName,
-        mp.client_name,
-        mp.client_tel,
-        mp.evaluate_amount,
-        mp.OWNER,
-        u.NAME AS HANDLER,
-        wn.CODE AS nodeCode,
-        mp.client_address
+            wfni.currentNodeId AS id,
+            wfni.nodeName,
+            wfni.productionName,
+            wfni.business_sub_id AS statementNo,
+            wfni.business_min_id AS reportNo,
+            m.id AS majorId,
+            m.created,
+            m.NAME,
+            m.order_id,
+            m.financial,
+            m.allot_type,
+            m.client_manager_id,
+            u.NAME AS clientManager,
+            m.principal_id,
+            u1.NAME AS principal,
+            m.department_id,
+            d.NAME AS department,
+            m.business_object_type,
+            m.clientele_id,
+            m.clientele_contact_id,
+            m.clientele_id AS clientele,
+            m.clientele_contact_id AS clienteleContact,
+            cc1.NAME AS cClienteleName,
+            cc2.NAME AS cClienteleSubName,
+            cl1.NAME AS cClienteleContactName,
+            cl1.mobile AS cMobile,
+            wfni.client_name,
+            wfni.client_tel,
+            wfni.evaluate_amount,
+            wfni.OWNER,
+            wfni.HANDLER,
+            wfni.nodeCode,
+            wfni.currentNodeId
         FROM
-        work_flow_node_instance wf
-        LEFT JOIN work_node wn ON wn.id = wf.node_id
-        LEFT JOIN ( SELECT report_no, major_id, NAME, client_name,client_address, client_tel, evaluate_amount, OWNER FROM major_production WHERE deleted = 0 ) mp ON ( mp.major_id = wf.business_id AND mp.report_no = ifnull( wf.business_min_id, wf.business_sub_id ) )
-        LEFT JOIN work_task_record wtr ON wtr.instance_id = wf.id
-        LEFT JOIN user u ON u.id = wtr.handler_id
-        WHERE
-        wf.business_type = 'MAJOR_BUSINESS'
-        AND wf.deleted = 0
-        AND wf.state = 'PENDING'
-        ) wfni ON wfni.business_id = m.id
-        LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
-        LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
-        LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
+            major m
+                LEFT JOIN user u ON u.id = m.client_manager_id
+                LEFT JOIN user u1 ON u1.id = m.principal_id
+                LEFT JOIN department d ON d.id = m.department_id
+                INNER JOIN (
+                SELECT
+                    wf.id AS currentNodeId,
+                    wf.node_id,
+                    wf.business_id,
+                    wf.business_sub_id,
+                    wf.business_min_id,
+                    wf.state,
+                    wn.NAME AS nodeName,
+                    mp.NAME AS productionName,
+                    mp.client_name,
+                    mp.client_tel,
+                    mp.evaluate_amount,
+                    mp.OWNER,
+                    u.NAME AS HANDLER,
+                    wn.CODE AS nodeCode,
+                    mp.client_address
+                FROM
+                    work_flow_node_instance wf
+                        LEFT JOIN work_node wn ON wn.id = wf.node_id
+                        LEFT JOIN ( SELECT report_no, major_id, NAME, client_name,client_address, client_tel, evaluate_amount, OWNER FROM major_production WHERE deleted = 0 ) mp ON ( mp.major_id = wf.business_id AND mp.report_no = ifnull( wf.business_min_id, wf.business_sub_id ) )
+                        LEFT JOIN work_task_record wtr ON wtr.instance_id = wf.id
+                        LEFT JOIN user u ON u.id = wtr.handler_id
+                WHERE
+                    wf.business_type = 'MAJOR_BUSINESS'
+                  AND wf.deleted = 0
+                  AND wf.state = 'PENDING'
+            ) wfni ON wfni.business_id = m.id
+                LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
+                LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
+                LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
         WHERE
-        m.deleted = 0
+            m.deleted = 0
+    </sql>
 
+    <select id="xPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
+        <include refid="majorPageSql" />
         <if test="keyword!=null and keyword!='' ">
             and (
             m.name like concat ('%',#{keyword},'%')
@@ -511,27 +514,169 @@
         <if test="major!=null and major.principalId!=null ">
             and m.principal_id = #{major.principalId}
         </if>
+        <if test="major!=null and major.departmentId!=null ">
+            and m.department_id = #{major.departmentId}
+        </if>
         <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
             and m.business_object_type = #{major.businessObjectType}
         </if>
+        <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
+            and (
+            m.principal_id in
+                <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">#{userId}
+                        </foreach>
+                   or
+                        m.client_manager_id  in
+                <foreach collection="
+            major.userIds" open="(" close=")" separator="," item="userId">#{userId}
+                        </foreach>
+                   or  JSON_CONTAINS(
+            JSON_EXTRACT(m.members, '$[*]'),CAST(#{currentUserId} AS CHAR))
+                )
+        </if>
+        order by wfni.currentNodeId DESC
+    </select>
+
+    <select id="pgLeaderPage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
+        <include refid="majorPageSql" />
+        <if test="keyword!=null and keyword!='' ">
+            and (
+            m.name like concat ('%',#{keyword},'%')
+            or m.order_id like concat('%',#{keyword},'%')
+            or u.name like concat('%',#{keyword},'%')
+            or u1.name like concat('%',#{keyword},'%')
+            or cc2.name like concat('%',#{keyword},'%')
+            or cc1.name like concat('%',#{keyword},'%')
+            or cl1.name like concat('%',#{keyword},'%')
+            or cl1.mobile like concat('%',#{keyword},'%')
+            or m.business_object_type like concat('%',#{keyword},'%')
+            or d.name like concat('%',#{keyword},'%')
+            or m.allot_type like concat('%',#{keyword},'%')
+            or wfni.client_name like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
+            or wfni.business_sub_id like concat('%',#{keyword},'%')
+            or wfni.owner like concat('%',#{keyword},'%')
+            or wfni.business_min_id like concat('%',#{keyword},'%')
+            or wfni.client_address like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
+            )
+        </if>
+        <if test="major!=null and major.financial!=null">
+            and m.financial = #{major.financial}
+        </if>
+        <if test="major!=null and major.startDate!=null and major.startDate!=''">
+            and m.created &gt;= #{major.startDate}
+        </if>
+        <if test="major!=null and major.endDate!=null and major.endDate!=''">
+            and m.created &lt;= #{major.endDate}
+        </if>
+        <if test="major!=null and major.nodeId!=null">
+            and wfni.node_id = #{major.nodeId}
+        </if>
+        <if test="major!=null and major.clientName!=null and major.clientName!=''">
+            and wfni.client_name like concat('%',#{major.clientName},'%')
+        </if>
+        <if test="major!=null and major.principalId!=null ">
+            and m.principal_id = #{major.principalId}
+        </if>
         <if test="major!=null and major.departmentId!=null ">
             and m.department_id = #{major.departmentId}
         </if>
-        <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
-           and (
-                    m.principal_id  in
-                    <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">
-                        #{userId}
-                    </foreach>
-               or
-                    m.client_manager_id  in
-                    <foreach collection="major.userIds" open="(" close=")" separator="," item="userId">
-                        #{userId}
-                    </foreach>
-               or  JSON_CONTAINS(JSON_EXTRACT(m.members, '$[*]'),CAST(#{currentUserId} AS CHAR))
+        <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
+            and m.business_object_type = #{major.businessObjectType}
+        </if>
+        order by wfni.currentNodeId DESC
+    </select>
 
+    <select id="scNonFinancePage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
+        <include refid="majorPageSql" />
+        and m.financial = 0
+        <if test="keyword!=null and keyword!='' ">
+            and (
+            m.name like concat ('%',#{keyword},'%')
+            or m.order_id like concat('%',#{keyword},'%')
+            or u.name like concat('%',#{keyword},'%')
+            or u1.name like concat('%',#{keyword},'%')
+            or cc2.name like concat('%',#{keyword},'%')
+            or cc1.name like concat('%',#{keyword},'%')
+            or cl1.name like concat('%',#{keyword},'%')
+            or cl1.mobile like concat('%',#{keyword},'%')
+            or m.business_object_type like concat('%',#{keyword},'%')
+            or d.name like concat('%',#{keyword},'%')
+            or m.allot_type like concat('%',#{keyword},'%')
+            or wfni.client_name like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
+            or wfni.business_sub_id like concat('%',#{keyword},'%')
+            or wfni.owner like concat('%',#{keyword},'%')
+            or wfni.business_min_id like concat('%',#{keyword},'%')
+            or wfni.client_address like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
             )
         </if>
+        <if test="major!=null and major.startDate!=null and major.startDate!=''">
+            and m.created &gt;= #{major.startDate}
+        </if>
+        <if test="major!=null and major.endDate!=null and major.endDate!=''">
+            and m.created &lt;= #{major.endDate}
+        </if>
+        <if test="major!=null and major.nodeId!=null">
+            and wfni.node_id = #{major.nodeId}
+        </if>
+        <if test="major!=null and major.clientName!=null and major.clientName!=''">
+            and wfni.client_name like concat('%',#{major.clientName},'%')
+        </if>
+        <if test="major!=null and major.principalId!=null ">
+            and m.principal_id = #{major.principalId}
+        </if>
+        <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
+            and m.business_object_type = #{major.businessObjectType}
+        </if>
+        order by wfni.currentNodeId DESC
+    </select>
+
+    <select id="scFinancePage" parameterType="com.dayou.vo.MajorVO" resultType="com.dayou.vo.MajorVO">
+        <include refid="majorPageSql" />
+        and m.financial = 1
+        <if test="keyword!=null and keyword!='' ">
+            and (
+            m.name like concat ('%',#{keyword},'%')
+            or m.order_id like concat('%',#{keyword},'%')
+            or u.name like concat('%',#{keyword},'%')
+            or u1.name like concat('%',#{keyword},'%')
+            or cc2.name like concat('%',#{keyword},'%')
+            or cc1.name like concat('%',#{keyword},'%')
+            or cl1.name like concat('%',#{keyword},'%')
+            or cl1.mobile like concat('%',#{keyword},'%')
+            or m.business_object_type like concat('%',#{keyword},'%')
+            or d.name like concat('%',#{keyword},'%')
+            or m.allot_type like concat('%',#{keyword},'%')
+            or wfni.client_name like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
+            or wfni.business_sub_id like concat('%',#{keyword},'%')
+            or wfni.owner like concat('%',#{keyword},'%')
+            or wfni.business_min_id like concat('%',#{keyword},'%')
+            or wfni.client_address like concat('%',#{keyword},'%')
+            or wfni.productionName like concat('%',#{keyword},'%')
+            )
+        </if>
+        <if test="major!=null and major.startDate!=null and major.startDate!=''">
+            and m.created &gt;= #{major.startDate}
+        </if>
+        <if test="major!=null and major.endDate!=null and major.endDate!=''">
+            and m.created &lt;= #{major.endDate}
+        </if>
+        <if test="major!=null and major.nodeId!=null">
+            and wfni.node_id = #{major.nodeId}
+        </if>
+        <if test="major!=null and major.clientName!=null and major.clientName!=''">
+            and wfni.client_name like concat('%',#{major.clientName},'%')
+        </if>
+        <if test="major!=null and major.principalId!=null ">
+            and m.principal_id = #{major.principalId}
+        </if>
+        <if test="major!=null and major.businessObjectType!=null and major.businessObjectType!=''">
+            and m.business_object_type = #{major.businessObjectType}
+        </if>
         order by wfni.currentNodeId DESC
     </select>
 
@@ -617,4 +762,26 @@
                 left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
 
     </select>
+
+    <select id="getDepartmentOrderOverStock" parameterType="java.lang.Long" resultType="java.lang.Integer">
+        SELECT
+            count(*)
+        FROM
+            major
+        WHERE
+            id IN (
+                SELECT
+                    business_id
+                FROM
+                    work_flow_node_instance
+                WHERE
+                    flow_id = 6
+                  AND business_type = 'MAJOR_BUSINESS'
+                  AND deleted = 0
+                  AND state = 'PENDING'
+                  AND node_id IN ( 55, 56, 57, 58, 59 ))
+          AND deleted = 0
+          AND allot_type = '轮单'
+          AND department_id = #{departmentId}
+    </select>
 </mapper>

+ 1 - 1
domain/src/main/java/com/dayou/vo/FinanceFineVO.java

@@ -111,7 +111,7 @@ public class FinanceFineVO {
     /**
      * 实际罚款⾦额
      */
-    @Excel(name = "实际罚款⾦额")
+//    @Excel(name = "实际罚款⾦额")
     private BigDecimal realFineAmount;
 
     /**

+ 13 - 0
domain/src/main/java/com/dayou/vo/MajorDepartmentVO.java

@@ -0,0 +1,13 @@
+package com.dayou.vo;
+
+import lombok.Data;
+
+@Data
+public class MajorDepartmentVO {
+
+    private Long id;
+
+    private String name;
+
+    private Integer orderOverStock;
+}

+ 2 - 0
service/src/main/java/com/dayou/service/IDepartmentService.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.dayou.entity.User;
 import com.dayou.vo.DepartmentStatVO;
 import com.dayou.vo.DepartmentVO;
+import com.dayou.vo.MajorDepartmentVO;
 import com.dayou.vo.UserVO;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
@@ -57,4 +58,5 @@ public interface IDepartmentService extends IService<Department> {
      */
     Long getManagerDepId(Long managerId);
 
+    List<MajorDepartmentVO> allotMajor();
 }

+ 4 - 0
service/src/main/java/com/dayou/service/IMajorService.java

@@ -54,4 +54,8 @@ public interface IMajorService extends IService<Major> {
     Boolean feedback(PriceFeedbackDTO priceFeedbackDTO);
 
     Boolean updateDepartment(TaskRecordDTO<Major> taskRecordDTO);
+
+    Integer getDepartmentOrderOverStock();
+
+    void checkOrderOverStock(Long departmentId);
 }

+ 8 - 0
service/src/main/java/com/dayou/service/impl/DepartmentServiceImpl.java

@@ -15,6 +15,7 @@ import com.dayou.service.IPostService;
 import com.dayou.service.IUserService;
 import com.dayou.vo.DepartmentStatVO;
 import com.dayou.vo.DepartmentVO;
+import com.dayou.vo.MajorDepartmentVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -26,6 +27,8 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Collections;
 import java.util.List;
 import java.util.ArrayList;
 import org.springframework.transaction.annotation.Transactional;
@@ -176,4 +179,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         return departmentMapper.getManagerDepId(managerId);
     }
 
+    @Override
+    public List<MajorDepartmentVO> allotMajor() {
+        return departmentMapper.allotMajor();
+    }
+
 }

+ 42 - 0
service/src/main/java/com/dayou/service/impl/MajorServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.dayou.bo.LoginCacheUserBO;
 import com.dayou.common.BaseEntity;
 import com.dayou.dto.*;
 import com.dayou.entity.*;
@@ -108,10 +109,14 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
     @Transactional
     @Override
     public WorkNodeCommit add(Major major){
+
         if (BY_TURNS.equals(major.getAllotType())){
             //确定接单部门
             Long allotDepartmentId = getAllotDepartmentId(MainBusinessEnum.MAJOR_BUSINESS);
             major.setDepartmentId(allotDepartmentId);
+        }else{
+            //指派单:校验轮单是否积压
+            checkOrderOverStock(major.getDepartmentId());
         }
         major.setOrderId(businessNumberService.takeOrderNumber());
         major.setMarketDepartmentId(departmentService.getManagerDepId(major.getClientManagerId()));
@@ -125,6 +130,7 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
 
     }
 
+
     @Override
     public Boolean update(Major major){
         return  this.updateById(major);
@@ -189,6 +195,23 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
 
     @Override
     public Page<MajorVO> xPage(Page page, MajorVO major, String keyword) {
+        //评估部经理查询
+        SimplePostModel post = LoginContext.getLoginCacheUserBO().getPostList().stream().filter(x -> x.getName().equals("评估部经理")).findFirst().orElse(null);
+        if (post!=null){
+            major.setDepartmentId(post.getDepartmentId());
+            return majorMapper.pgLeaderPage(page,major,keyword);
+        }
+        //市场部非金融数据权限查询
+        SimplePostModel post1 = LoginContext.getLoginCacheUserBO().getPostList().stream().filter(x -> x.getName().equals("大中型-非金融数据权限岗")).findFirst().orElse(null);
+        if (post1!=null){
+            return majorMapper.scNonFinancePage(page,major,keyword);
+        }
+        //市场部金融数据权限查询
+        SimplePostModel post2 = LoginContext.getLoginCacheUserBO().getPostList().stream().filter(x -> x.getName().equals("大中型-金融数据权限岗")).findFirst().orElse(null);
+        if (post2!=null){
+            return majorMapper.scFinancePage(page,major,keyword);
+        }
+        //其他查询
         return majorMapper.xPage(page,major,keyword,LoginContext.getCurrentUserId());
     }
 
@@ -258,6 +281,25 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
         return this.update(new LambdaUpdateWrapper<Major>().set(Major::getDepartmentId,taskData.getDepartmentId()).eq(Major::getId,taskData.getId()));
     }
 
+    @Override
+    public Integer getDepartmentOrderOverStock() {
+        LoginCacheUserBO loginCacheUserBO = LoginContext.getLoginCacheUserBO();
+        SimplePostModel post = loginCacheUserBO.getPostList().stream().filter(x -> x.getName().equals("评估部经理")).findFirst().orElse(null);
+        if (post!=null){
+            Long departmentId = post.getDepartmentId();
+            return majorMapper.getDepartmentOrderOverStock(departmentId);
+        }
+        return 0;
+    }
+
+    @Override
+    public void checkOrderOverStock(Long departmentId) {
+        if (majorMapper.getDepartmentOrderOverStock(departmentId)>2){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"该部门轮单已积压,无法指派到该部门。");
+        }
+
+    }
+
 //    /**
 //     * 大中型业务下单
 //     * @param businessId