123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <?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.AssetsMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.Assets">
- <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="assets_business_gener" property="assetsBusinessGener"/>
- <result column="entrust_again" property="entrustAgain"/>
- <result column="clientele_type" property="clienteleType"/>
- <result column="clientele_id" property="clienteleId"/>
- <result column="clientele_sub_id" property="clienteleSubId"/>
- <result column="clientele_contact_id" property="clienteleContactId"/>
- <result column="security" property="security"/>
- <result column="significant_assets_reorganization" property="significantAssetsReorganization"/>
- <result column="state_assets" property="stateAssets"/>
- <result column="foreign_assets_involved" property="foreignAssetsInvolved"/>
- <result column="dispense_benefit" property="dispenseBenefit"/>
- <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="terminal_clientele_id" property="terminalClienteleId"/>
- <result column="terminal_clientele_type" property="terminalClienteleType"/>
- <result column="terminal_clientele_contact_id" property="terminalClienteleContactId"/>
- <result column="members" property="members"/>
- <result column="remark" property="remark"/>
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- deleted,
- created,
- modified,
- name, order_id, financial, allot_type, client_manager_id, principal_id, department_id, assets_business_gener, entrust_again, clientele_type, clientele_id, clientele_sub_id, clientele_contact_id, security, significant_assets_reorganization, state_assets, foreign_assets_involved, dispense_benefit, bailor, bailor_address, bailor_contact_name, bailor_contact_tel, terminal_clientele_id, terminal_clientele_type, terminal_clientele_contact_id, members, remark
- </sql>
- <!--条件查询资产任务列表-->
- <select id="selectPage" resultType="com.dayou.vo.AssetsVO">
- SELECT (@i := @i + 1) AS id,
- assets.id AS assetsId,
- assets.name,
- order_id,
- assets_business_gener,
- allot_type,
- production_no,
- clientele_id,
- customer.name AS customerName,
- bailor,
- bailor_contact_tel,
- assets.created,
- #查询客户经理
- (SELECT name FROM user WHERE id = assets.client_manager_id) AS clientManagerName,
- #查询项目负责人
- (SELECT name FROM user WHERE id = assets.principal_id) AS principalName,
- #查询业务来源(即子级客户)
- (SELECT customer_company.name FROM customer_company WHERE customer_company.id = clientele_sub_id) AS customerSubName,
- nodeInfo.businessId,
- nodeInfo.currentNodeName,
- nodeInfo.currentNodeCode,
- nodeInfo.handlerName,
- production_type
- FROM (SELECT @i := 0) AS sort,assets
- LEFT JOIN assets_production AS production ON production.business_id = assets.id
- LEFT JOIN user ON user.id = assets.principal_id
- LEFT JOIN customer_company AS customer ON customer.id = assets.clientele_id
- #查询当前进行的节点信息(并使用左连接)
- LEFT JOIN (SELECT nodeInstance.id AS currentNodeId,
- user.name AS handlerName,
- node.name AS currentNodeName,
- node.code AS currentNodeCode,
- nodeInstance.business_id AS businessId
- FROM work_flow_node_instance AS nodeInstance,
- work_task_record AS record,
- user,
- work_node AS node
- WHERE state = 'PENDING'
- AND nodeInstance.node_id = node.id
- AND record.handler_id = user.id
- AND nodeInstance.deleted = 0
- AND record.instance_id = nodeInstance.id
- # 根据处理节点查询(节点code)
- <if test="assetsSelectDTO != null and assetsSelectDTO.nodeCode != null and assetsSelectDTO.nodeCode != '' ">
- AND node.`code` = #{assetsSelectDTO.nodeCode}
- </if>
- ) AS nodeInfo ON nodeInfo.businessId = assets.id
- WHERE assets.deleted = 0
- #评估业务类别(业务类型)查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.assetsBusinessGener != null and assetsSelectDTO.assetsBusinessGener != '' ">
- AND assets.assets_business_gener = #{assetsSelectDTO.assetsBusinessGener}
- </if>
- #项目负责人查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.principalId != null">
- AND assets.principal_id = #{assetsSelectDTO.principalId}
- </if>
- #客户经理查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.clientManagerId != null">
- AND assets.client_manager_id = #{assetsSelectDTO.clientManagerId}
- </if>
- #关键字模糊查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.keyWord != null and assetsSelectDTO.keyWord != '' ">
- AND (
- assets.order_id LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- assets.name LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- production.production_no LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- customer.name LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%')
- )
- </if>
- ORDER BY assets.created DESC
- </select>
- <!--条件查询我的资产任务订单列表-->
- <select id="selectMyOrderPage" resultType="com.dayou.vo.AssetsVO">
- SELECT (@i := @i + 1) AS id,
- assets.id AS assetsId,
- assets.name,
- assets.order_id,
- assets_business_gener,
- allot_type,
- production.production_no,
- clientele_id,
- customer.name AS customerName,
- bailor,
- bailor_contact_name,
- bailor_contact_tel,
- assets.created,
- ( SELECT SUM(estimated_value) FROM assets_evaluation_target WHERE assets_evaluation_target.assets_id = assets.id ) AS estimated_value,
- fund.should_amount,
- fund.real_amount,
- fund.discount,
- pFund.standard_amount,
- invoice.real_amount AS invoiceRealAmount,
- #查询客户经理
- (SELECT name FROM user WHERE id = assets.client_manager_id) AS clientManagerName,
- #查询项目负责人
- (SELECT name FROM user WHERE id = assets.principal_id) AS principalName,
- #查询业务来源(即子级客户)
- (SELECT customer_company.name FROM customer_company WHERE customer_company.id = clientele_sub_id) AS customerSubName,
- nodeInfo.businessId,
- nodeInfo.currentNodeName,
- nodeInfo.currentNodeCode,
- nodeInfo.handlerName,
- production.production_type
- FROM (SELECT @i := 0) AS sort,assets
- LEFT JOIN assets_production AS production ON production.business_id = assets.id
- LEFT JOIN user ON user.id = assets.principal_id
- LEFT JOIN customer_company AS customer ON customer.id = assets.clientele_id
- LEFT JOIN order_fund AS fund ON fund.business_id = assets.id
- LEFT JOIN production_fund AS pFund ON pFund.business_id = assets.id
- LEFT JOIN finance_invoice AS invoice ON pFund.order_fund_id = fund.id
- #查询当前进行的节点信息
- LEFT JOIN (SELECT nodeInstance.id AS currentNodeId,
- user.name AS handlerName,
- node.name AS currentNodeName,
- node.code AS currentNodeCode,
- nodeInstance.business_id AS businessId
- FROM work_flow_node_instance AS nodeInstance,
- work_task_record AS record,
- user,
- work_node AS node
- WHERE state = 'PENDING'
- AND nodeInstance.node_id = node.id
- AND record.handler_id = user.id
- AND nodeInstance.deleted = 0
- AND record.instance_id = nodeInstance.id
- ) AS nodeInfo ON nodeInfo.businessId = assets.id
- WHERE assets.deleted = 0
- AND assets.client_manager_id = #{assetsSelectDTO.clientManagerId}
- #送达状态查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.delivery != null">
- AND production.delivery = #{assetsSelectDTO.delivery}
- </if>
- #项目负责人查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.principalId != null">
- AND assets.principal_id = #{assetsSelectDTO.principalId}
- </if>
- #关键字模糊查询
- <if test="assetsSelectDTO != null and assetsSelectDTO.keyWord != null and assetsSelectDTO.keyWord != '' ">
- AND (
- assets.order_id LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- assets.name LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- production.production_no LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
- customer.name LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%')
- )
- </if>
- ORDER BY assets.created DESC
- </select>
- <!--根据业务id获取资产业务详情-->
- <select id="getAssetsDetailById" resultType="com.dayou.vo.AssetsVO">
- SELECT assets.id,
- #查询客户经理
- (SELECT name FROM user WHERE id = assets.client_manager_id) AS clientManagerName,
- user.name AS principalName,
- allot_type,
- assets.department_id,
- assets.order_id,
- assets.name,
- assets.assets_business_gener,
- assets.entrust_again,
- assets.clientele_type,
- assets.principal_id,
- customer.id AS clienteleId,
- customer.name AS customerName,
- linkman.id AS clienteleContactId,
- linkman.name AS linkmanName,
- linkman.department AS linkmanDepartment,
- linkman.duty AS linkmanDuty,
- linkman.mobile AS linkmanMobile,
- assets.security,
- assets.significant_assets_reorganization,
- assets.state_assets,
- assets.foreign_assets_involved,
- assets.dispense_benefit,
- assets.bailor,
- assets.bailor_address,
- assets.bailor_contact_name,
- assets.bailor_contact_tel,
- assets.terminal_clientele_id,
- assets.terminal_clientele_type,
- assets.remark,
- tLinkman.id AS tLinkmanId,
- tLinkman.name AS tLinkmanName,
- tLinkman.mobile AS tLinkmanMobile,
- assets.members AS members,
- #查询终端客户名称
- (SELECT customer_company.name FROM customer_company WHERE customer_company.id = assets.terminal_clientele_id) AS
- terminalClienteleName,
- assets.clientele_sub_id
- FROM assets
- LEFT JOIN user ON user.id = assets.principal_id
- LEFT JOIN department ON department.id = assets.department_id
- LEFT JOIN customer_company AS customer ON customer.id = assets.clientele_id
- LEFT JOIN customer_linkman AS linkman ON linkman.id = assets.clientele_contact_id
- LEFT JOIN (SELECT tLinkman.id, tLinkman.name, tLinkman.mobile FROM customer_linkman AS tLinkman) AS tLinkman ON
- tLinkman.id = assets.terminal_clientele_contact_id
- <where>
- <if test="id != null">
- AND assets.id = #{id}
- </if>
- </where>
- </select>
- <!--根据业务id获取资产业务款项信息-->
- <select id="getOrderFundInvoiceById" resultType="com.dayou.vo.AssetsOrderFundInvoiceVO">
- SELECT order_fund.id,
- business_id,
- should_amount,
- order_fund.real_amount,
- title,
- type,
- tax_no,
- bank_name,
- bank_account,
- bank_address,
- bank_tel
- FROM order_fund
- LEFT JOIN finance_invoice ON finance_invoice.order_fund_id = order_fund.id
- WHERE order_fund.business_id = #{id}
- AND order_fund.deleted = 0
- </select>
- <!--根据业务类型与取号类型获取业务取号信息-->
- <select id="getBusinessNum" resultType="com.dayou.entity.BusinessNumber">
- SELECT id, year, month, next_no
- FROM business_number
- WHERE take_type = #{takeType}
- AND business_type = #{businessType}
- AND year = #{year}
- AND deleted = 0
- </select>
- <!--新增取号信息-->
- <insert id="addBusinessNum">
- INSERT INTO business_number(id, take_type, business_type, year, month, next_no)
- VALUE (NULL, #{takeType}, #{businessType}, #{year}, #{month}, #{nextNo})
- </insert>
- <!--更新取号信息-->
- <update id="updateBusinessNum">
- UPDATE business_number
- SET month = #{month},
- next_no = #{nextNo}
- WHERE id = #{id}
- </update>
- </mapper>
|