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
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
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},'%')
)
and m.financial = #{major.financial}
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
ORDER BY
created DESC
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
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},'%')
)
and m.financial = #{major.financial}
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
and wfni.nodeCode = #{major.nodeCode}
and wfni.client_name like concat('%',#{major.clientName},'%')
and m.client_manager_id = #{major.clientManagerId}
and m.principal_id = #{major.principalId}
and m.business_object_type = #{major.businessObjectType}
and m.department_id = #{major.departmentId}
order by wfni.modified DESC
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
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 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
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
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},'%')
)
and m.financial = #{major.financial}
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
and wfni.node_id = #{major.nodeId}
and cc1.name like concat('%',#{major.clienteleName},'%')
and cc2.name like concat('%',#{major.clienteleSubName},'%')
and m.client_manager_id = #{major.clientManagerId}
and m.principal_id = #{major.principalId}
and m.department_id = #{major.departmentId}
and m.business_object_type = #{major.businessObjectType}
and (
m.principal_id in
#{userId}
or
m.client_manager_id in
#{userId}
or JSON_CONTAINS(
JSON_EXTRACT(m.members, '$[*]'),CAST(#{currentUserId} AS CHAR))
)
order by wfni.currentNodeId DESC
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},'%')
)
and m.financial = #{major.financial}
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
and wfni.node_id = #{major.nodeId}
and cc1.name like concat('%',#{major.clienteleName},'%')
and cc2.name like concat('%',#{major.clienteleSubName},'%')
and m.principal_id = #{major.principalId}
and m.client_manager_id = #{major.clientManagerId}
and m.department_id = #{major.departmentId}
and m.business_object_type = #{major.businessObjectType}
order by wfni.currentNodeId DESC
and m.financial = 0
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},'%')
)
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
and wfni.node_id = #{major.nodeId}
and cc1.name like concat('%',#{major.clienteleName},'%')
and cc2.name like concat('%',#{major.clienteleSubName},'%')
and m.principal_id = #{major.principalId}
and m.business_object_type = #{major.businessObjectType}
or
m.client_manager_id in
#{userId}
order by wfni.currentNodeId DESC
and m.financial = 1
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},'%')
)
and m.created >= #{major.startDate}
and m.created <= #{major.endDate}
and wfni.node_id = #{major.nodeId}
and cc1.name like concat('%',#{major.clienteleName},'%')
and cc2.name like concat('%',#{major.clienteleSubName},'%')
and m.principal_id = #{major.principalId}
and m.business_object_type = #{major.businessObjectType}
and
m.client_manager_id in
#{userId}
order by wfni.currentNodeId DESC
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
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
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}