12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262 |
- <?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.tofly.workflow.report.mapper.ReportMapper">
- <select id="settlementCount" resultType="com.tofly.workflow.report.vo.SettlementVo">
- select
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- b.project_name,
- b.REGION_NAME || ' ' || ADDRE address,
- b.user_phone,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,
- b.household_number,
- re.PAYMENT_DATE ,
- re.amount,
- (select name from sys_dict where id =re.charge_mode) charge_mode,
- (select REAL_NAME from sys_user where id =b.duty_user) duty_user ,
- (select REAL_NAME from sys_user where id =node.handle_user) hand_User ,
- (select name from sys_tenant where id =(select tenant_id from sys_user where id =node.handle_user))
- handle_tenant,
- re.remark
- from TF_PROJECT_BASE_W b
- left join tf_process_l c on b.process_id = c.id
- left join tf_process_config_l d on ( c.config_id = d.id )
- left join tf_process_config_step_l s on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node on
- (node.config_id = s.config_id and node.PROCESS_STEP = s.step_order and node.edition = s.edition and
- b.process_id = node.process_id
- )
- left join TF_CHARGE_REFUND_W re on re.node_id = node.id
- where
- c.is_del = 0
- and d.is_del = 0
- and d.is_valid =1
- and s.is_valid =1
- and s.is_del=0
- and node.is_valid =1
- and node.is_del = 0
- and (s.step_name='用户结算' or s.step_name='结算办理')
- and re.id is not null
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- order by PROJECT_NAME
- </select>
- <select id="getSignAndApplyData" resultType="com.tofly.workflow.report.vo.SignApplyVo">
- select b.PROJECT_NAME,
- b. APPLY_USER_NAME,
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- b.REGISTER_TIME,
- b.REGION_NAME || ' ' || ADDRE address,
- b.USER_PHONE,
- (select REAL_NAME from sys_user where id = duty_user) duty_user,-- 勘察人,
- b.SURVEY_DATE SURVEY_DATE,-- 勘察日期
- b.HOUSEHOLD_NUMBER ,--申请户数
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,--工程性质
- b.INSTALL_CONTENT, --安装内容
- b.process_id,
- m.NAME LABEL_NAME,
- (select REAL_NAME from sys_user where id = b.REGISTER_STAFF) REGISTER_STAFF_NAME
- from TF_PROJECT_BASE_W b
- left join tf_process_l c on b.process_id = c.id
- LEFT JOIN
- (
- SELECT
- PROCESS_ID,
- MAX( h.ID ) ID
- FROM TF_NOW_HANDLE_L h
- LEFT JOIN TF_CONFIG_STEP_USER_L su ON ( h.STEP_ID = su.STEP_ID AND h.STEP_NODE = su.STEP_NODE )
- WHERE
- su.USER_TYPE = 1
- GROUP BY
- PROCESS_ID
- ) h ON b.PROCESS_ID = h.PROCESS_ID
- LEFT JOIN TF_NOW_HANDLE_L nh ON ( b.PROCESS_ID = nh.PROCESS_ID AND h.ID = nh.ID )
- LEFT JOIN SYS_MENU m ON nh.LABEL = m.ID
- where
- 1=1
- and c.is_del = 0
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null ">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null ">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- </select>
- <select id="getDispatchCount" resultType="com.tofly.workflow.report.vo.ProjectDispatchVo">
- select duty_post_name,duty_user,
- count(case when user_type='商业' then 1 end ) sysl,
- count(case when user_type='工业' then 1 end ) gysl,
- count(case when user_type='公服' then 1 end) gfsl,
- count(case when user_type='集中小区' then 1 end) jzxqsl,
- count(case when user_type='民用' then 1 end)mysl,
- count(case when user_type='商业' or user_type='工业' or user_type='公服' then 1 end) fjxqsl,
- sum(case when user_type='集中小区' then HOUSEHOLD_NUMBER else 0 end ) jzxq_hs,
- sum(case when user_type='民用' then HOUSEHOLD_NUMBER else 0 end ) my_hs,
- count(1) project_number,
- nvl(sum(HOUSEHOLD_NUMBER),0) household_total
- from(
- select ( select name from SYS_POST where id = a.duty_post and DELETED != 1 ) duty_post_name,
- (select REAL_NAME from sys_user where id =DUTY_USER ) DUTY_USER,
- (select name from SYS_DICT where id = a.user_type) user_type,
- HOUSEHOLD_NUMBER
- from TF_PROJECT_BASE_W a where 1=1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and a.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null ">
- and a.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and a.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND a.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- ) group by duty_post_name,duty_user
- </select>
- <select id="getNotInProjectVo" resultType="com.tofly.workflow.report.vo.NotInProjectVo">
- select PROJECT_NAME,
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,--工程性质
- REGION_NAME || ' ' || ADDRE address,
- HOUSEHOLD_NUMBER ,--申请户数
- REGISTER_TIME, --申请日期
- CONTACTS, --联系人
- USER_PHONE, --联系电话
- (select REAL_NAME from sys_user where id =duty_user) duty_user , --负责人
- SURVEY_DATE SURVEY_DATE,-- 勘察日期
- DATA_TIME,-- 派工日期
- n6.handle_time jfrq -- 缴费日期
- from TF_PROJECT_BASE_W b
- left join
- (
- select n.handle_time,n.process_id from tf_process_node_l n
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '合同签订及用户缴费' )
- ) n6 on n6.process_id = b.process_id
- where 1=1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- and b.id not in(
- select id from (
- select x.*,
- case
- when(type_name='新安装工程' and STEP_NAME='技术交底' and x.handle_id is null )then '1'
- when(type_name='户内改造工程' and STEP_NAME='工程派工' and x.handle_id is null ) then '1'
- when(type_name='新安装工程' and STEP_NAME='工程派工' )then '3'
- else '0'
- end as status
- from (
- select a.*,
- d.node_id,
- d.step_name,
- h.id handle_id,
- (select type_name from TF_BASE_TYPE_P where id = a.process_type) type_name
- from TF_PROJECT_BASE_W a
- left join (select b.process_id,
- b.id node_id,
- b.config_id ,
- b.step_name,
- b.edition,
- b.label
- from tf_process_node_l b
- where (b.step_name = '技术交底' or b.step_name = '工程派工')
- and b.is_valid = 1
- and b.is_del = 0
- and b.node_state = 2) d
- on( a.process_id = d.process_id and a.config_id = d.config_id)
- left join tf_now_handle_l h on (a.process_id =h.process_id and d.label = h.label and d.edition = h.edition)
- ) x
- ) where status =1 and (type_name ='户内改造工程' or type_name ='新安装工程')
- )
- </select>
- <select id="preIncomeCount" resultType="com.tofly.workflow.report.vo.PreIncomeVo">
- select (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- b.project_name,
- b.region_name || b.addre address,
- b.user_phone,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,
- b.household_number,
- re.amount,
- (select name from sys_dict where id = re.charge_mode) charge_mode,
- (select REAL_NAME from sys_user where id = node.handle_user) hand_User,
- re.remark,
- re.PAYMENT_DATE
- from TF_PROJECT_BASE_W b
- left join tf_process_l c
- on b.process_id = c.id
- left join tf_process_config_l d
- on (c.config_id = d.id)
- left join tf_process_config_step_l s
- on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node
- on (node.config_id = s.config_id and node.PROCESS_STEP = s.step_order and
- node.edition = s.edition and b.process_id = node.process_id)
- left join TF_CHARGE_REFUND_W re
- on re.node_id = node.id
- where c.is_del = 0
- and d.is_del = 0
- and d.is_valid = 1
- and s.is_valid = 1
- and s.is_del = 0
- and node.is_valid = 1
- and node.is_del = 0
- and (s.step_name = '合同签订及用户缴费' or s.step_name = '用户缴费')
- and re.amount is not null
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- order by PROJECT_NAME
- </select>
- <select id="hasChargeCount" resultType="com.tofly.workflow.report.vo.HasChargeVo">
- select
- b.process_id,
- b.project_name,
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,
- b.region_name || b.addre address,
- b.household_number,
- b.register_time ,
- b.contacts contact_user ,
- user_Phone,
- (select REAL_NAME from sys_user where id =b.duty_user) duty_user ,
- b.survey_Date surveyDate,
- b.budget budget,
- b.budget/household_number budgetAvg,
- -- b.advance_Payment,
- re.amount,
- re.payment_date
- from TF_PROJECT_BASE_W b
- left join tf_process_l c on b.process_id = c.id
- left join tf_process_config_l d on ( c.config_id = d.id )
- left join tf_process_config_step_l s on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node on
- (node.config_id = s.config_id and node.PROCESS_STEP = s.step_order and node.edition = s.edition and
- b.process_id = node.process_id
- )
- left join TF_CHARGE_REFUND_W re on re.node_id = node.id
- where
- c.is_del = 0
- and d.is_del = 0
- and d.is_valid =1
- and s.is_valid =1
- and s.is_del=0
- and node.is_valid =1
- and node.is_del = 0
- and (s.step_name='合同签订及用户缴费' or s.step_name='用户缴费' or s.STEP_NAME='合同签订及缴费')
- and re.amount is not null
- --and b.project_name='(隐患户)安昌重庆安逸包'
- --and b.process_id=1699077770691317761
- --and re.id is not null
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- order by PROJECT_NAME
- </select>
- <select id="acceptCount" resultType="com.tofly.workflow.report.vo.AcceptVo">
- select b.project_name,
- b.process_id,
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- --process_type,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,
- b.region_name || b.addre address,
- b.household_number,
- b.register_time,
- b.contacts contact_user,
- user_Phone,
- n6.handle_time pay_Handle_Time,
- (select REAL_NAME from sys_user where id = b.duty_user) duty_user,
- b.survey_Date surveyDate,
- --缴费日期,
- b.data_Time dispatch_date, --派工日期
- (select name from SYS_DEPT where id = b.build_Unit) build_unit_name , -- 施工单位
- ( select name from TF_CONSTRUCTION_TEAM_P where id = b.team_Id) team_name , -- 施工班组
- (select REAL_NAME from sys_user where id = b.build_User_Id) build_user_name, --施工负责人
- ( select min(n1.create_time) from tf_process_node_l n1
- left join tf_process_l p1 on n1.process_id = p1.id
- where n1.is_valid = 1 and n1.is_del=0
- and p1.is_del=0
- and p1.relation_id =b.process_id
- and n1.step_name = '工程领料'
- ) first_apply_time , -- 领料日期
- ( select min(n1.create_time) from tf_process_node_l n1
- left join tf_process_l p1 on n1.process_id = p1.id
- where n1.is_valid = 1 and n1.is_del=0
- and p1.is_del=0
- and p1.relation_id =b.process_id
- and n1.step_name = '工程退料'
- ) first_Refund_Time, -- 日期
- n2.create_time commit_time, -- 提交验收申请日期,
- --验收结果
- x.result_message,
- --验收合格日期
- x.throw_time
- -- 退料日期
- from TF_PROJECT_BASE_W b
- -- left join tf_process_node_l n on (n.process_id = p.id )
- left join tf_process_node_l n2 on (n2.process_id = b.process_id)
- left join
- (
- select n.handle_time,n.process_id from tf_process_node_l n
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '合同签订及用户缴费' )
- ) n6 on n6.process_id = b.process_id
- left join (
- select *from (
- select case
- when count_throw = total then
- '合格'
- when count_bh > 0 then
- '不合格'
- else
- '审核中'
- end result_message,
- throw_time,
- process_id
- from (
- select
- n.process_id,
- count(1) total,
- count(case
- when NODE_STATE = 2 then
- 1
- end) count_throw,
- count(case
- when NODE_STATE = 3 then
- 1
- end) count_bh,
- max(HANDLE_TIME) throw_time
- --select *
- from tf_process_node_l n
- left join (
- select l.step_name,l.config_id,l.edition,l.step_order
- from tf_process_config_step_l l
- left join tf_process_config_step_l l2
- on (l.config_id = l2.config_id
- and l.edition = l2.edition
- and l.upper_step = to_char(l2.step_order))
- where l2.step_name='综合验收'
- ) x on ( n.process_step = x.step_order and n.config_id = x.config_id and n.edition = x.edition)
- where x.step_name is not null and n.is_valid = 1 and n.is_del = 0
- group by n.process_id
- )
- )
- ) x on b.process_id =x.process_id
- where
- --p.is_del = 0
- -- and n.is_valid =1
- -- and n.is_del=0
- n2.is_valid =1
- and n2.is_del=0
- and ( n2.step_name = '综合验收' )
- and process_type=1568576682649546753
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- -- and n.step_name='领料确认'
- order by PROJECT_NAME
- </select>
- <select id="completeCount" resultType="com.tofly.workflow.report.vo.CompleteVo">
- select b.project_name,
- b.process_id,
- (select type_name from TF_BASE_TYPE_P where id = b.process_type) process_type_name,
- (select name from SYS_DICT where id = user_type) PROJECT_NATURE,
- b.region_name || b.addre address,
- b.household_number,
- b.register_time,
- b.contacts contact_user,
- user_Phone,
- (select REAL_NAME from sys_user where id = b.duty_user) duty_user,
- b.survey_Date surveyDate,
- b.budget,
- b.budget/b.household_number avgBudget,
- b.advance_payment ,
- n6.handle_time pay_handle_time ,
- b.data_Time dispatch_date,
- (select name from SYS_DEPT where id = b.build_Unit) build_unit_name ,
- ( select name from TF_CONSTRUCTION_TEAM_P where id = b.team_Id) team_name ,
- (select REAL_NAME from sys_user where id = b.build_User_Id) build_user_name,
- nl.create_time first_apply_time ,
- nt.create_time lfirst_Refund_Time,
- b.apply_date,
- b.total_Price charge_Number,
- x.result_message,
- x.throw_time ,
- n3.handle_time charge_handle_time ,
- n5.handle_time complete_handle_time,
- n2.create_time commitTime
- from TF_PROJECT_BASE_W b
- left join(
- select *from tf_process_node_l n where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '综合验收' )
- ) n2 on n2.process_id = b.process_id
- left join
- (
- select re.amount,n.handle_time,n.process_id from tf_process_node_l n
- left join TF_CHARGE_REFUND_W re on re.node_id = n.id
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '用户结算' )
- ) n3 on n3.process_id = b.process_id
- left join
- (
- select n.number_value,n.handle_time,n.process_id from tf_process_node_l n
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '工程结算' )
- ) n4 on n4.process_id = b.process_id
- left join
- (
- select n.handle_time,n.process_id from tf_process_node_l n
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '竣工资料移交' )
- ) n5 on n5.process_id = b.process_id
- left join
- (
- select n.handle_time,n.process_id from tf_process_node_l n
- where n.is_valid =1
- and n.is_del=0
- and ( n.step_name = '合同签订及用户缴费' )
- ) n6 on n6.process_id = b.process_id
- left join (
- select *from (
- select case
- when count_throw = total then
- '合格'
- when count_bh > 0 then
- '不合格'
- else
- '审核中'
- end result_message,
- throw_time,
- process_id
- from (
- select
- n.process_id,
- count(1) total,
- count(case
- when NODE_STATE = 2 then
- 1
- end) count_throw,
- count(case
- when NODE_STATE = 3 then
- 1
- end) count_bh,
- max(HANDLE_TIME) throw_time
- from tf_process_node_l n
- left join (
- select l.step_name,l.config_id,l.edition,l.step_order
- from tf_process_config_step_l l
- left join tf_process_config_step_l l2
- on (l.config_id = l2.config_id
- and l.edition = l2.edition
- and l.upper_step = to_char(l2.step_order))
- where l2.step_name='综合验收'
- ) x on ( n.process_step = x.step_order and n.config_id = x.config_id and n.edition = x.edition)
- where x.step_name is not null and n.is_valid = 1 and n.is_del = 0
- group by n.process_id
- )
- )
- ) x on b.process_id =x.process_id
- left join (
- select p1.relation_id ,min(n1.create_time) create_time from tf_process_node_l n1
- left join tf_process_l p1 on n1.process_id = p1.id
- where n1.is_valid = 1 and n1.is_del=0
- and p1.is_del=0
- and n1.step_name = '工程退料'
- group by p1.relation_id
- ) nt on nt.relation_id = b.process_id
- left join (
- select p1.relation_id ,min(n1.create_time) create_time from tf_process_node_l n1
- left join tf_process_l p1 on n1.process_id = p1.id
- where n1.is_valid = 1 and n1.is_del=0
- and p1.is_del=0
- and n1.step_name = '工程领料'
- group by p1.relation_id
- ) nl on nl.relation_id = b.process_id
- where
- process_type=1568576682649546753
- and b.apply_date is not null
- and n5.handle_time is not null
- and n3.handle_time is not null
- and x.result_message is not null
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- <if test="reportDto.keywords !=null and reportDto.keywords !=''">
- and (
- instr(PROJECT_NAME,#{reportDto.keywords})>0
- or
- instr (REGION_NAME,#{reportDto.keywords})>0
- or
- instr (ADDRE,#{reportDto.keywords})>0
- or
- instr (USER_PHONE,#{reportDto.keywords})>0
- )
- </if>
- <if test="reportDto.processTypes!=null and reportDto.processTypes!=''.toString()">
- AND b.process_type in
- <foreach item="item" index="index" collection="reportDto.processTypes.split(',')" open="(" separator=","
- close=")">
- #{item}
- </foreach>
- </if>
- <if test="reportDto.projectNatureIds!=null and reportDto.projectNatureIds!=''.toString()">
- AND user_type in
- <foreach item="item" index="index" collection="reportDto.projectNatureIds.split(',')" open="("
- separator="," close=")">
- #{item}
- </foreach>
- </if>
- </if>
- order by PROJECT_NAME
- </select>
- <select id="allRoundCount" resultType="com.tofly.workflow.report.vo.AllRoundVo">
- select
- (select type_name from TF_BASE_TYPE_P where id = a.process_type) process_type_name,
- a.total_household_number,
- a.register_number,
- a1.ct has_charge, --已缴费数
- a.register_number - a2.ct2 no_begin, --未开工数
- a2.ct2 has_begin,--已开工数
- a7.ct complete_Num, --工程完结归档
- a4.ct has_accept, -- 已验收
- a.register_number-a4.ct no_accept , --未验收
- a5.ct has_settle , --工程结算
- a6.ct to_Regular_Count--转固数量
- from (
- select b.process_type, -- 工程类型
- sum(b.household_number) total_household_number, --总户数
- count(case
- when b.register_time is not null then
- 1
- end) register_number -- 工程登记数
- from TF_PROJECT_BASE_W b
- where 1=1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by process_type ) a
- left join (
- select b.process_type,
- count(case
- when node.handle_time is not null then
- 1
- end) ct
- from TF_PROJECT_BASE_W b
- left join tf_process_l c
- on b.process_id = c.id
- left join tf_process_config_l d
- on (c.config_id = d.id)
- left join tf_process_config_step_l s
- on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node
- on (node.config_id = s.config_id and
- node.PROCESS_STEP = s.step_order and
- node.edition = s.edition and
- b.process_id = node.process_id)
- where 1 = 1
- and d.is_del = 0
- and d.is_valid = 1
- and s.is_valid = 1
- and s.is_del = 0
- and (s.step_name = '合同签订及用户缴费' or s.step_name = '用户缴费')
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by b.process_type) a1
- on a.process_type = a1.process_type
- left join (
- select b.process_type,
- count(case
- when node.handle_time is null then
- 1
- end) ct,
- count(case
- when node.handle_state = 1 then
- 1
- end) ct2
- from TF_PROJECT_BASE_W b
- left join tf_process_l c
- on b.process_id = c.id
- left join tf_process_config_l d
- on (c.config_id = d.id)
- left join tf_process_config_step_l s
- on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node
- on (node.config_id = s.config_id and
- node.PROCESS_STEP = s.step_order and
- node.edition = s.edition and
- b.process_id = node.process_id)
- where 1 = 1
- and d.is_del = 0
- and d.is_valid = 1
- and s.is_valid = 1
- and s.is_del = 0
- and (s.step_name = '开工报告')
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by b.process_type) a2
- on a.process_type = a2.process_type
- left join (
- select b.process_type,
- count(case
- when node.handle_time is null then
- 1
- end) ct,
- count(case
- when node.handle_state = 1 then
- 1
- end) ct2
- from TF_PROJECT_BASE_W b
- left join tf_process_l c
- on b.process_id = c.id
- left join tf_process_config_l d
- on (c.config_id = d.id)
- left join tf_process_config_step_l s
- on (d.id = s.config_id and b.edition = s.edition)
- left join tf_process_node_l node
- on (node.config_id = s.config_id and
- node.PROCESS_STEP = s.step_order and
- node.edition = s.edition and
- b.process_id = node.process_id)
- where 1 = 1
- and d.is_del = 0
- and d.is_valid = 1
- and s.is_valid = 1
- and s.is_del = 0
- and (s.step_name = '工程验收')
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by b.process_type) a3
- on a.process_type = a3.process_type
- left join (
- select PROCESS_TYPE,count(1) ct
- from TF_PROJECT_BASE_W b
- left join tf_process_node_l n2
- on (n2.process_id = b.process_id)
- where n2.step_name = '综合验收'
- and n2.handle_time is not null
- and n2.is_valid = 1
- and n2.is_del = 0
- and HANDLE_STATE= 1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by PROCESS_TYPE
- ) a4 on a.process_type = a4.process_type
- left join (
- select PROCESS_TYPE,count(1) ct
- from TF_PROJECT_BASE_W b
- left join tf_process_node_l n2
- on (n2.process_id = b.process_id)
- where (n2.step_name = '用户结算' or n2.step_name = '结算办理')
- and n2.handle_time is not null
- and n2.is_valid = 1
- and n2.is_del = 0
- and HANDLE_STATE= 1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by PROCESS_TYPE
- ) a5 on a.process_type = a5.process_type
- left join (
- select PROCESS_TYPE,count(1) ct
- from TF_PROJECT_BASE_W b
- left join tf_process_node_l n2
- on (n2.process_id = b.process_id)
- where n2.step_name = '转固'
- and n2.handle_time is not null
- and n2.is_valid = 1
- and n2.is_del = 0
- and HANDLE_STATE= 1
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and b.tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and b.REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and b.REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by PROCESS_TYPE
- ) a6 on a.process_type = a6.process_type
- left join(
- select process_type, count(1) ct from tf_process_l where PROCESS_STATE = '4'
- <if test="reportDto !=null">
- <if test="reportDto.tenantId !=null and reportDto.tenantId !='' ">
- and tenant_id=#{reportDto.tenantId}
- </if>
- <if test="reportDto.beginTime !=null">
- and REGISTER_TIME>= #{reportDto.beginTime}
- </if>
- <if test="reportDto.endTime !=null">
- <![CDATA[ and REGISTER_TIME < =#{reportDto.endTime} ]]>
- </if>
- </if>
- group by process_type
- ) a7 on a.process_type = a7.process_type
- </select>
- <select id="getTotalAmount" resultType="java.lang.Long">
- select sum(amount)
- from TF_CHARGE_REFUND_W c
- inner join TF_PROCESS_NODE_L n on c.NODE_ID=n.id
- where c.PROCESS_ID = #{processId}
- and n.IS_VALID=1
- </select>
- <select id="getContract" resultType="com.tofly.workflow.report.vo.ContractVo">
- select *
- from (select coalesce(contract.TOTAL_CONTRACT, 0) TOTAL_CONTRACT,
- coalesce(contract.DEDUCT_EXPENSES, 0) DEDUCT_EXPENSES,
- coalesce(contract.WATER_ELECTRICITY, 0) WATER_ELECTRICITY,
- dist.name as settlementMode
- from tf_contract_w contract
- inner join SYS_DICT dist on contract.SETTLEMENT_MODE = dist.id
- inner join TF_PROCESS_NODE_L node on contract.NODE_ID=node.id
- WHERE contract.process_id = #{processId}
- and node.IS_VALID=1
- order by contract.id desc)
- where ROWNUM = 1
- </select>
- <select id="getProcessTypeList" resultType="com.tofly.workflow.report.vo.ProcessType">
- select project.PROCESS_ID,
- type.type_name
- from TF_PROJECT_BASE_W project
- inner join TF_BASE_TYPE_P type on project.process_type = type.id
- inner join TF_PROCESS_L process on project.PROCESS_ID = process.ID
- where process.PASSING_NODE is not null
- and process.IS_DEL=0
- <if test="tenantId !=null and tenantId !='' ">
- and project.tenant_id=#{tenantId}
- </if>
- <if test="beginTime !=null">
- and project.REGISTER_TIME >= #{beginTime}
- </if>
- <if test="endTime !=null">
- and project.REGISTER_TIME <= #{endTime}
- </if>
- </select>
- <select id="getHasStep" resultType="java.lang.String">
- select count(1)
- from TF_PROCESS_L p
- inner join (select distinct PROCESS_ID
- from TF_PROCESS_NODE_L pn
- inner join SYS_MENU sm on pn.LABEL = sm.ID
- where
- pn.IS_VALID = 1
- and sm.name = #{stepName}
- and pn.NODE_STATE = 2
- and pn.PROCESS_ID not in (select PROCESS_ID
- from TF_PROCESS_NODE_L pn2
- inner join SYS_MENU sm on pn2.LABEL = sm.ID
- where
- pn2.IS_VALID = 1
- and sm.name = #{stepName}
- and pn2.NODE_STATE != 2)) n
- on p.ID = n.PROCESS_ID
- where
- p.id in
- <foreach collection="processIdList" item="id" separator="," open="(" close=")">
- #{id}
- </foreach>
- </select>
- <select id="getToRegularCount" resultType="java.lang.String">
- select count(1) from (
- select * from TF_TRANSFER_FIXED_ASSETS_W t inner join TF_PROCESS_L p on p.ID = t.PROCESS_ID
- <where>
- <if test="processIdList !=null and processIdList.size() > 0 ">
- p.ID in
- <foreach collection="processIdList" item="id" separator="," open="(" close=")">
- #{id}
- </foreach>
- </if>
- </where>
- ) t
- </select>
- <select id="getHouseHoldNumber" resultType="java.lang.String">
- select sum(HOUSEHOLD_NUMBER) from TF_REGISTER_ITEM_W
- <where>
- <if test="processIdList !=null and processIdList.size() > 0 ">
- PROCESS_ID in
- <foreach collection="processIdList" item="id" separator="," open="(" close=")">
- #{id}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getChargeWList" resultType="com.tofly.workflow.buss.entity.TfChargeW">
- select c.*
- from TF_CHARGE_W c
- inner join TF_PROCESS_NODE_L n on c.NODE_ID = n.id
- where c.PROCESS_ID = #{processId}
- and n.IS_VALID = 1
- </select>
- </mapper>
|