123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <?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.MajorProductionMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.MajorProduction">
- <result column="id" property="id" />
- <result column="major_id" property="majorId" />
- <result column="deleted" property="deleted" />
- <result column="created" property="created" />
- <result column="modified" property="modified" />
- <result column="report_no" property="reportNo" />
- <result column="production" property="production" />
- <result column="signatory" property="signatory" />
- <result column="name" property="name" />
- <result column="client_name" property="clientName" />
- <result column="client_tel" property="clientTel" />
- <result column="client_address" property="clientAddress" />
- <result column="owner" property="owner" />
- <result column="value_timing" property="valueTiming" />
- <result column="evaluate_acreage" property="evaluateAcreage" />
- <result column="evaluate_amount" property="evaluateAmount" />
- <result column="evaluate_price" property="evaluatePrice" />
- <result column="comment" property="comment" />
- <result column="qr_code" property="qrCode" />
- <result column="repertory_state" property="repertoryState" />
- <result column="first_check" property="firstCheck" />
- <result column="second_check" property="secondCheck" />
- <result column="third_check" property="thirdCheck" />
- <result column="save_file_check" property="saveFileCheck" />
- <result column="save_file_second_check" property="saveFileSecondCheck" />
- <result column="if_save_file" property="ifSaveFile" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- major_id,
- deleted,
- created,
- modified,
- report_no, production,signatory, name, client_name, client_tel, client_address, owner, value_timing, evaluate_acreage, evaluate_amount, evaluate_price
- , comment,qr_code,repertory_state,first_check,second_check,third_check,save_file_check,save_file_second_check,if_save_file
- </sql>
- <select id="getList" parameterType="com.dayou.entity.MajorProduction" resultType="com.dayou.entity.MajorProduction">
- select * from (
- SELECT
- mp.id,
- mp.major_id,
- (SELECT id FROM work_flow_node_instance
- WHERE business_id = #{production.majorId}
- AND (business_sub_id = mp.report_no or business_min_id = mp.report_no ) and deleted = 0
- and sequence = ( #{production.sequence} + 1) ) AS nextInstanceNodeId ,
- mp.report_no,
- mp.production,
- mp.signatory,
- mp.`name`,
- mp.client_name,
- mp.client_tel,
- mp.client_address,
- mp.`owner`,
- mp.value_timing,
- mp.evaluate_acreage,
- mp.evaluate_amount,
- mp.evaluate_price,
- mp.`comment`,
- mp.qr_code,
- mp.repertory_state,
- mp.first_check,
- mp.second_check,
- mp.third_check,
- mp.save_file_check,
- mp.save_file_second_check,
- mp.if_save_file,
- mp.file_path,
- m.`name` AS majorName
- FROM
- major_production mp
- LEFT JOIN major m ON m.id = mp.major_id
- WHERE
- mp.major_id = #{production.majorId}
- <if test="production!=null and production.afterProduction==null and production.reportNo!=null and production.reportNo!='' ">
- and mp.report_no = #{production.reportNo}
- </if>
- <if test="production!=null and production.afterProduction!=null and production.afterProduction=='REPORT' and production.reportNo!=null and production.reportNo!='' ">
- and mp.report_no in (select report_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
- </if>
- <if test="production!=null and production.afterProduction!=null and production.afterProduction=='LETTER' and production.reportNo!=null and production.reportNo!='' ">
- and mp.report_no in (select letter_no from major_target where major_id = #{production.majorId} and statement_no =#{production.reportNo} and deleted = 0)
- </if>
- <if test="production!=null and production.production!=null and production.production!='' ">
- and mp.production = #{production.production}
- </if>
- and mp.deleted = 0 and m.deleted = 0
- order by mp.created ASC ) t where nextInstanceNodeId is null
- </select>
- <select id="saveDonePage" parameterType="com.dayou.vo.MajorProductionSaveDoneVO" resultType="com.dayou.vo.MajorProductionSaveDoneVO">
- SELECT
- mp.id,
- mp.name,
- mp.major_id,
- mp.report_no,
- m.order_id,
- m.name as orderName,
- u1.name as clientManager,
- u2.name as principal,
- m.business_object_type,
- mp.production,
- mp.repertory_state,
- mp.save_file_date,
- pf.real_amount
- FROM
- major_production mp
- LEFT JOIN major m ON m.id = mp.major_id
- LEFT JOIN user u1 ON u1.id = m.client_manager_id
- LEFT JOIN user u2 ON u2.id = m.principal_id
- left join (select business_id,production_no,real_amount, production_type from production_fund where business_type='MAJOR_BUSINESS' and deleted = 0) pf
- on (pf.business_id = mp.major_id and pf.production_no =mp.report_no and mp.production = pf.production_type)
- where mp.deleted = 0 and m.deleted = 0 and mp.if_save_file= 1
- <if test="keyword!=null and keyword!='' ">
- and (
- mp.name like concat('%',#{keyword},'%')
- or m.order_id like concat('%',#{keyword},'%')
- or m.name like concat('%',#{keyword},'%')
- or u1.NAME like concat('%',#{keyword},'%')
- or u2.NAME like concat('%',#{keyword},'%')
- or mp.report_no like concat('%',#{keyword},'%')
- )
- </if>
- <if test="done!=null and done.production!=null and done.production!=''">
- and mp.production =#{done.production}
- </if>
- <if test="done!=null and done.startDate!=null and done.startDate!=''">
- and mp.save_file_date >= #{done.startDate}
- </if>
- <if test="done!=null and done.endDate!=null and done.endDate!=''">
- and mp.save_file_date <= #{done.endDate}
- </if>
- order by mp.save_file_date desc
- </select>
- <select id="getHouse" parameterType="com.dayou.vo.MajorProductionVO" resultType="com.dayou.vo.MajorProductionVO">
- SELECT
- mp.id,
- mp.major_id,
- mp.report_no,
- mp.production,
- mp.NAME,
- mp.client_name,
- mp.evaluate_amount,
- mp.repertory_state,
- mp.repertory_in_time,
- u.NAME AS principal
- FROM
- major_production mp
- LEFT JOIN major m ON m.id = mp.major_id
- LEFT JOIN user u ON u.id = m.principal_id
- where mp.deleted = 0 and m.deleted = 0 and mp.repertory_state=0
- <if test="keyword!=null and keyword!='' ">
- and (
- mp.report_no like concat ('%',#{keyword},'%')
- or mp.NAME like concat('%',#{keyword},'%')
- or mp.client_name like concat('%',#{keyword},'%')
- or mp.evaluate_amount like concat('%',#{keyword},'%')
- or u.NAME like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.production!=null and vo.production!=''">
- and mp.production =#{vo.production}
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and mp.repertory_in_time >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and mp.repertory_in_time <= #{vo.endDate}
- </if>
- order by mp.repertory_in_time DESC
- </select>
- <sql id="myMajorOrder">
- SELECT
- m.id,
- m.order_id,
- m.name as orderName,
- u.name as principal,
- u1.name as clientManager,
- cc.name as clienteleName,
- cc1.name as clienteleSubName,
- cl.name as clienteleContactName,
- m.bailor,
- m.owner,
- m.created,
- orf.id as orderFundId,
- orf.should_amount,
- orf.real_amount,
- orf.remark
- FROM
- major m
- left join user u on u.id = m.principal_id
- left join user u1 on u1.id = m.client_manager_id
- left join customer_company cc on cc.id = m.clientele_id
- left join customer_company cc1 on cc1.id = m.clientele_sub_id
- left join customer_linkman cl on cl.id = m.clientele_contact_id
- left join (select * from order_fund where business_type ='MAJOR_BUSINESS' and deleted = 0) orf on orf.business_id = m.id
- </sql>
- <select id="myOrder" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
- <include refid="myMajorOrder" />
- where m.deleted = 0
- and m.client_manager_id = #{vo.clientManagerId}
- <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 cc.name like concat('%',#{keyword},'%')
- or cc1.name like concat('%',#{keyword},'%')
- or cl.name like concat('%',#{keyword},'%')
- or m.bailor like concat('%',#{keyword},'%')
- or m.owner like concat('%',#{keyword},'%')
- or orf.should_amount like concat('%',#{keyword},'%')
- or orf.real_amount like concat('%',#{keyword},'%')
- or orf.remark like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and m.created >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and m.created <= #{vo.endDate}
- </if>
- order by m.created DESC
- </select>
- <select id="waitingClaim" parameterType="com.dayou.vo.MajorOrderVO" resultType="com.dayou.vo.MajorOrderVO">
- <include refid="myMajorOrder" />
- where m.deleted = 0
- and m.client_manager_id = #{vo.clientManagerId} and orf.id is not null
- order by m.created DESC
- </select>
- <select id="getMajorProductionAboutFundId" parameterType="java.lang.Long" resultType="com.dayou.entity.MajorProduction">
- SELECT
- mp.id,
- pf.id as productionFundId,
- pf.real_amount,
- mp.production,
- mp.NAME,
- mp.client_name,
- mp.OWNER,
- mp.evaluate_acreage,
- mp.evaluate_amount,
- mp.evaluate_price,
- mp.report_no,
- mp.repertory_state,
- mp.repertory_in_time,
- mp.repertory_out_time,
- mp.if_save_file,
- mp.save_file_date,
- mp.delivery
- FROM
- major_production mp
- LEFT JOIN ( SELECT id, business_id, production_no,real_amount,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON (
- mp.major_id = pf.business_id
- AND mp.report_no = pf.production_no and mp.production = pf.production_type) where mp.major_id = #{majorId} and mp.deleted = 0
- and mp.name is not null
- <if test="reportNo!=null and reportNo!=''">
- and mp.report_no = #{reportNo}
- </if>
- order by mp.id DESC
- </select>
- <select id="todoSaveFilePage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
- SELECT
- wfni.id,
- mp.id AS productionId,
- mp.NAME,
- mp.repertory_state,
- wtr.id AS taskId,
- wfni.id AS currentNodeId,
- wfni.business_min_id ,
- wfni.business_id,
- m.NAME AS orderName,
- m.order_id,
- u1.NAME AS clientManager,
- u2.NAME AS principal,
- d.NAME AS departmentName,
- wfni.NAME AS nodeName,
- wfni.CODE AS nodeCode,
- u.NAME AS HANDLER,
- pf.real_amount AS realAmount,
- wtr.handler_id,
- wtr.finished AS taskFinished,
- DATE_FORMAT( m.created, '%Y-%m-%d' ) AS created,
- wtr.created AS taskCreated,
- mp.production
- FROM
- work_task_record wtr
- LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
- INNER JOIN (
- SELECT
- wn.NAME,
- wn.CODE,
- wfni.id,
- wfni.business_id,
- wfni.business_sub_id,
- wfni.business_min_id,
- wfni.state
- 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
- AND wn.CODE = 'BUSINESS_ARCHIVING'
- ) wfni ON wtr.instance_id = wfni.id
- LEFT JOIN major m ON m.id = wfni.business_id
- LEFT JOIN USER u ON u.id = wtr.handler_id
- LEFT JOIN USER u1 ON u1.id = m.client_manager_id
- LEFT JOIN USER u2 ON u2.id = m.principal_id
- LEFT JOIN department d ON d.id = m.department_id
- LEFT JOIN ( SELECT id, major_id, report_no, NAME, repertory_state, production FROM major_production WHERE production != 'STATEMENT' AND deleted = 0 ) mp ON ( mp.major_id = m.id AND mp.report_no = wfni.business_min_id )
- LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON (
- pf.business_id = m.id
- AND pf.production_no = wfni.business_min_id)
- WHERE u.deleted = 0
- and wtr.handler_id =#{todoVO.handlerId}
- AND wnt.deleted = 0
- AND wtr.deleted = 0
- <if test="keyword!=null and keyword!='' ">
- and (
- mp.name like concat('%',#{keyword},'%')
- or m.order_id like concat('%',#{keyword},'%')
- or m.name like concat('%',#{keyword},'%')
- or wfni.business_min_id like concat('%',#{keyword},'%')
- or u1.NAME like concat('%',#{keyword},'%')
- or u2.NAME like concat('%',#{keyword},'%')
- )
- </if>
- <if test="todoVO!=null and todoVO.production!=null and todoVO.production!=''">
- and mp.production =#{todoVO.production}
- </if>
- ORDER BY
- wtr.created DESC
- </select>
- <update id="updateSaveFileInfo" parameterType="java.util.List">
- update major_production set if_save_file = 1 ,save_file_date= now() where id in (
- <foreach collection="productionIds" index="index" item="item" separator=",">
- #{item}
- </foreach>
- )
- </update>
- </mapper>
|