123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dayou.mapper.MajorMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.Major">
- <result column="id" property="id" />
- <result column="deleted" property="deleted" />
- <result column="created" property="created" />
- <result column="modified" property="modified" />
- <result column="name" property="name" />
- <result column="order_id" property="orderId" />
- <result column="financial" property="financial" />
- <result column="allot_type" property="allotType" />
- <result column="client_manager_id" property="clientManagerId" />
- <result column="principal_id" property="principalId" />
- <result column="department_id" property="departmentId" />
- <result column="business_object_type" property="businessObjectType" />
- <result column="special_type" property="specialType" />
- <result column="business_gener" property="businessGener" />
- <result column="evaluate_aim" property="evaluateAim" />
- <result column="entrust_again" property="entrustAgain" />
- <result column="multiple_removal" property="multipleRemoval" />
- <result column="informal_evaluate" property="informalEvaluate" />
- <result column="clientele_type" property="clienteleType" />
- <result column="clientele_id" property="clienteleId" />
- <result column="clientele_contact_id" property="clienteleContactId" />
- <result column="dispense_benefit" property="dispenseBenefit" />
- <result column="nonnative" property="nonnative" />
- <result column="refinance" property="refinance" />
- <result column="loan_limit" property="loanLimit" />
- <result column="loan_period" property="loanPeriod" />
- <result column="loan_nature" property="loanNature" />
- <result column="loan_aim" property="loanAim" />
- <result column="loan_expire" property="loanExpire" />
- <result column="bailor" property="bailor" />
- <result column="bailor_address" property="bailorAddress" />
- <result column="bailor_contact_name" property="bailorContactName" />
- <result column="bailor_contact_tel" property="bailorContactTel" />
- <result column="owner" property="owner" />
- <result column="owner_tel" property="ownerTel" />
- <result column="urgent" property="urgent" />
- <result column="terminal_clientele_id" property="terminalClienteleId" />
- <result column="terminal_clientele_type" property="terminalClienteleType" />
- <result column="terminal_clientele_contact_id" property="terminalClienteleContactId" />
- <result column="remark" property="remark" />
- <result column="members" property="members" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- deleted,
- created,
- modified,
- name, order_id, financial, allot_type, client_manager_id, principal_id, department_id, business_object_type, special_type, business_gener,
- evaluate_aim, entrust_again, multiple_removal, informal_evaluate, clientele_type, clientele_id, clientele_contact_id, dispense_benefit,
- nonnative, refinance, loan_limit, loan_period, loan_nature, loan_aim, loan_expire, bailor, bailor_address, bailor_contact_name,
- bailor_contact_tel, owner, owner_tel, urgent, terminal_clientele_id, terminal_clientele_type, terminal_clientele_contact_id, remark,members,
- production_info,printing,printing_remark
- </sql>
- <resultMap id="majorVoMap" type="com.dayou.vo.MajorListVO">
- <result column="id" property="id" />
- <result column="created" property="created" />
- <result column="name" property="name" />
- <result column="order_id" property="orderId" />
- <result column="financial" property="financial" />
- <result column="allot_type" property="allotType" />
- <result column="client_manager_id" property="clientManagerId" />
- <result column="clientManager" property="clientManager" />
- <result column="principal_id" property="principalId" />
- <result column="principal" property="principal" />
- <result column="department_id" property="departmentId" />
- <result column="departmentName" property="departmentName" />
- <result column="business_object_type" property="businessObjectType" />
- <result column="clientele_id" property="clienteleId" />
- <result column="clientele" property="clientele" />
- <result column="clientele_contact_id" property="clienteleContactId" />
- <result column="clienteleContact" property="clienteleContact" />
- <result column="clienteleContactTel" property="clienteleContactTel" />
- <result column="currentNodeId" property="currentNodeId" />
- <result column="currentNodeName" property="currentNodeName" />
- <result column="cClienteleName" property="cClienteleName" />
- <result column="cClienteleSubName" property="cClienteleSubName" />
- <result column="cClienteleContactName" property="cClienteleContactName" />
- <result column="cMobile" property="cMobile" />
- <collection property="productions" ofType="com.dayou.vo.MajorProductionVO" select="selectProduction" column="id"/>
- </resultMap>
- <select id="getPage" parameterType="com.dayou.vo.MajorVO" resultMap="majorVoMap">
- SELECT
- DISTINCT
- m.id,
- 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 departmentName,
- 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
- 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 ( SELECT id, node_id, business_id, business_sub_id, state FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' and deleted = 0 and 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
- <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},'%')
- )
- </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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- ORDER BY
- created DESC
- </select>
- <select id="getTerminatedPage" 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,
- wfni.`comment`
- 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 (
- 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,
- wf.modified,
- wf.`comment`
- 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 = 'CLOSED'
- ) 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
- <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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- <if test="major!=null and major.nodeCode!=null and major.nodeCode!=''">
- and wfni.nodeCode = #{major.nodeCode}
- </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.clientManagerId!=null ">
- and m.client_manager_id = #{major.clientManagerId}
- </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>
- <if test="major!=null and major.departmentId!=null ">
- and m.department_id = #{major.departmentId}
- </if>
- order by wfni.modified DESC
- </select>
- <select id="selectProduction" parameterType="java.lang.Long" resultType="com.dayou.vo.MajorProductionVO">
- select *,sum(amount) as realAmount from (SELECT
- mp.id,
- mp.report_no,
- mp.name,
- mp.client_name,
- mp.client_tel,
- mp.evaluate_acreage,
- mp.evaluate_amount,
- mp.repertory_state,
- mp.if_save_file,
- wfni.id AS currentNodeId,
- wn.name AS currentNodeName,
- wfni.state,
- mp.major_id,
- pf.real_amount as amount
- FROM
- (select * from major_production where major_id = #{id} and deleted = 0) mp left join
- ( SELECT id, node_id, business_id, business_sub_id, state FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 AND business_id = #{id} and state='PENDING' ) wfni
- ON ( wfni.business_id = mp.major_id AND mp.report_no = wfni.business_sub_id )
- LEFT JOIN (select id,name from work_node where deleted =0) wn ON wn.id = wfni.node_id
- left join (select business_id,business_sub_id,real_amount,production_type from production_fund where deleted = 0) pf on (pf.business_id = mp.major_id and pf.business_sub_id = mp.report_no and pf.production_type = mp.production)) t GROUP BY report_no
- order by id DESC
- </select>
- <select id="getDetail" parameterType="java.lang.Long" resultType="com.dayou.vo.MajorVO">
- SELECT
- m.id,
- m.created,
- m.NAME,
- m.order_id,
- m.financial,
- m.allot_type,
- m.client_manager_id,
- m.principal_id,
- m.department_id,
- m.business_object_type,
- m.special_type,
- m.business_gener,
- m.evaluate_aim,
- m.entrust_again,
- m.multiple_removal,
- m.informal_evaluate,
- m.clientele_type,
- m.clientele_id,
- m.clientele_sub_id,
- m.clientele_contact_id,
- m.dispense_benefit,
- m.nonnative,
- m.refinance,
- m.loan_limit,
- m.loan_period,
- m.loan_nature,
- m.loan_aim,
- m.loan_expire,
- m.bailor,
- m.bailor_address,
- m.bailor_contact_name,
- m.bailor_contact_tel,
- m.OWNER,
- m.owner_tel,
- m.urgent,
- m.terminal_clientele_id,
- m.terminal_clientele_type,
- m.terminal_clientele_contact_id,
- m.remark,
- m.members,
- m.feedback_info,
- m.evaluate_unit,
- u.NAME AS clientManager ,
- cc1.name as cClienteleName,
- cc2.name as cClienteleSubName,
- cl1.name as cClienteleContactName,
- cl1.mobile as cMobile,
- cl1.department as cDepartment,
- cl1.duty as cDuty,
- cc3.name as tTerminalClienteleName,
- cc3.phone as tCompanyMobile,
- cl2.name as tTerminalClienteleContactName,
- cl2.mobile as tMobile
- FROM
- major m
- LEFT JOIN user u ON u.id = m.client_manager_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
- left join customer_company cc3 on cc3.id = m.terminal_clientele_id
- left join customer_linkman cl2 on cl2.id = m.terminal_clientele_contact_id where m.id =#{id}
- </select>
- <select id="staticsInformation" resultType="com.dayou.dto.MajorStaticsDTO">
- SELECT
- (SELECT count(wfni.id) FROM
- work_task_record wtr
- LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
- INNER JOIN (
- SELECT wfni.id FROM
- work_flow_node_instance wfni
- LEFT JOIN work_node wn ON wn.id = wfni.node_id
- WHERE
- wfni.business_type = 'MAJOR_BUSINESS'
- AND wfni.state = 'PENDING'
- AND wfni.deleted = 0
- AND wn.deleted = 0
- ) wfni ON wtr.instance_id = wfni.id WHERE
- wtr.handler_id =#{userId}
- AND wnt.deleted = 0
- AND wtr.deleted = 0 ) as majorToDo,
- (SELECT count(*) FROM work_flow_log WHERE handler_id = #{userId} and business_type='MAJOR_BUSINESS') as majorDone,
- ( SELECT count(*) FROM major_production WHERE deleted = 0 AND if_save_file = 1 ) AS saveFileCount,
- ( SELECT count(*) FROM work_flow_node_instance WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 AND state = 'PENDING' ) AS pending,
- ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'STATEMENT' and repertory_state is not null ) AS statementCount,
- ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'REPORT' and repertory_state is not null ) AS reportCount,
- ( SELECT count(*) FROM major_production WHERE deleted = 0 AND production = 'LETTER' and repertory_state is not null ) AS letterCount,
- ( SELECT count(*) FROM major_production WHERE deleted = 0 AND repertory_state = 0 ) AS inWarehouseCount
- </select>
- <sql id="majorPageSql">
- 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 (
- 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
- </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},'%')
- 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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- <if test="major!=null and major.nodeId!=null">
- and wfni.node_id = #{major.nodeId}
- </if>
- <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
- and cc1.name like concat('%',#{major.clienteleName},'%')
- </if>
- <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
- and cc2.name like concat('%',#{major.clienteleSubName},'%')
- </if>
- <if test="major!=null and major.clientManagerId!=null ">
- and m.client_manager_id = #{major.clientManagerId}
- </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.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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- <if test="major!=null and major.nodeId!=null">
- and wfni.node_id = #{major.nodeId}
- </if>
- <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
- and cc1.name like concat('%',#{major.clienteleName},'%')
- </if>
- <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
- and cc2.name like concat('%',#{major.clienteleSubName},'%')
- </if>
- <if test="major!=null and major.principalId!=null ">
- and m.principal_id = #{major.principalId}
- </if>
- <if test="major!=null and major.clientManagerId!=null ">
- and m.client_manager_id = #{major.clientManagerId}
- </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>
- 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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- <if test="major!=null and major.nodeId!=null">
- and wfni.node_id = #{major.nodeId}
- </if>
- <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
- and cc1.name like concat('%',#{major.clienteleName},'%')
- </if>
- <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
- and cc2.name like concat('%',#{major.clienteleSubName},'%')
- </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>
- <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
- or
- m.client_manager_id in
- <foreach collection="
- major.userIds" open="(" close=")" separator="," item="userId">#{userId}
- </foreach>
- </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 >= #{major.startDate}
- </if>
- <if test="major!=null and major.endDate!=null and major.endDate!=''">
- and m.created <= #{major.endDate}
- </if>
- <if test="major!=null and major.nodeId!=null">
- and wfni.node_id = #{major.nodeId}
- </if>
- <if test="major!=null and major.clienteleName!=null and major.clienteleName!=''">
- and cc1.name like concat('%',#{major.clienteleName},'%')
- </if>
- <if test="major!=null and major.clienteleSubName!=null and major.clienteleSubName!=''">
- and cc2.name like concat('%',#{major.clienteleSubName},'%')
- </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>
- <if test="major!=null and major.userIds!=null and major.userIds.size!=0">
- and
- m.client_manager_id in
- <foreach collection="
- major.userIds" open="(" close=")" separator="," item="userId">#{userId}
- </foreach>
- </if>
- order by wfni.currentNodeId DESC
- </select>
- <select id="findMajorSubClient" resultType="com.dayou.dto.MajorSubClientDTO">
- SELECT
- m.id,
- m.clientele_sub_id,
- (select id from customer_company where deleted = 0 and parent_id = m.clientele_id and name = cc.NAME limit 1) as realSubId
- FROM
- major m
- LEFT JOIN customer_company cc ON (m.clientele_sub_id = cc.id )
- WHERE
- m.deleted = 0 and cc.level = 1
- </select>
- <select id="productionDetail" resultType="com.dayou.vo.MajorVO">
- SELECT
- m.id,
- mp.report_no as productionNo,
- mp.evaluate_acreage,
- mp.evaluate_amount/10000 as evaluateAmount,
- m.created,
- m.NAME,
- m.order_id,
- m.financial,
- m.allot_type,
- m.client_manager_id,
- m.principal_id,
- m.department_id,
- m.business_object_type,
- m.special_type,
- m.business_gener,
- m.evaluate_aim,
- m.entrust_again,
- m.multiple_removal,
- m.informal_evaluate,
- m.clientele_type,
- m.clientele_id,
- m.clientele_sub_id,
- m.clientele_contact_id,
- m.dispense_benefit,
- m.nonnative,
- m.refinance,
- m.loan_limit,
- m.loan_period,
- m.loan_nature,
- m.loan_aim,
- m.loan_expire,
- m.bailor,
- m.bailor_address,
- m.bailor_contact_name,
- m.bailor_contact_tel,
- m.OWNER,
- m.owner_tel,
- m.urgent,
- m.terminal_clientele_id,
- m.terminal_clientele_type,
- m.terminal_clientele_contact_id,
- m.remark,
- m.members,
- m.feedback_info,
- u.NAME AS clientManager ,
- cc1.name as cClienteleName,
- cc2.name as cClienteleSubName,
- cl1.name as cClienteleContactName,
- cl1.mobile as cMobile,
- cl1.department as cDepartment,
- cl1.duty as cDuty,
- cc3.name as tTerminalClienteleName,
- cc3.phone as tCompanyMobile,
- cl2.name as tTerminalClienteleContactName,
- cl2.mobile as tMobile
- FROM
- major m
- LEFT JOIN user u ON u.id = m.client_manager_id
- left join (select major_id,report_no, evaluate_acreage,evaluate_amount from major_production where major_id = #{id} and report_no = #{productionNo} and deleted=0 and production = #{production}) mp on mp.major_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
- left join customer_company cc3 on cc3.id = m.terminal_clientele_id
- 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 financial = 1
- and created <=DATE_SUB(NOW(), INTERVAL 7 DAY)
- AND department_id = #{departmentId}
- </select>
- </mapper>
|