<?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="cn.gistack.sm.sjztmd.mapper.TbProjectMapper">
|
<!--namespace根据自己需要创建的的mapper的路径和名称填写-->
|
<sql id="selectResByRegion">
|
SELECT arb."code",
|
arb."name",
|
arb."eng_scal",
|
case when town."ad_grad" = 4 THEN town."ad_code" ELSE NULL END AS townCode,
|
case when town."ad_grad" = 4 THEN town."ad_name" ELSE NULL END AS townName,
|
case
|
when town."ad_grad" = 3 THEN town."ad_code"
|
when county."ad_grad" = 3 THEN county."ad_code" END AS countyCode,
|
case
|
when town."ad_grad" = 3 THEN town."ad_name"
|
when county."ad_grad" = 3 THEN county."ad_name" END AS countyName,
|
case
|
when town."ad_grad" = 2 THEN town."ad_code"
|
when county."ad_grad" = 2 THEN county."ad_code"
|
ELSE city."ad_code" END AS cityCode,
|
case
|
when town."ad_grad" = 2 THEN town."ad_name"
|
when county."ad_grad" = 2 THEN county."ad_name"
|
ELSE city."ad_name" END AS cityName,
|
case
|
when town."ad_grad" = 1 THEN town."ad_code"
|
when county."ad_grad" = 1 THEN county."ad_code"
|
when city."ad_grad" = 1 THEN city."ad_code"
|
ELSE province."ad_code" END AS provinceCode,
|
case
|
when town."ad_grad" = 1 THEN town."ad_name"
|
when county."ad_grad" = 1 THEN county."ad_name"
|
when city."ad_grad" = 1 THEN city."ad_name"
|
ELSE province."ad_name" END AS provinceName
|
FROM sjzt_MD."att_res_base" ARB
|
LEFT JOIN YWXT."att_ad_base" town ON town."ad_code" = arb."interior_ad_guid"
|
LEFT JOIN YWXT."att_ad_base" county ON county."ad_code" = town."p_ad_code"
|
LEFT JOIN YWXT."att_ad_base" city ON city."ad_code" = county."p_ad_code"
|
LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = city."p_ad_code"
|
</sql>
|
<update id="updateallcheck">
|
update SJZT_MD."tb_project" set set "is_fill" ='', "check_state" ='';
|
</update>
|
<update id="updateFill">
|
update SJZT_MD."tb_project_fill" set "isFil" = #{params.isFil}, "start_time" = #{params.stratTime},"end_time"= #{params.endTime}
|
</update>
|
|
<select id="getList" resultType="cn.gistack.sm.sjztmd.vo.TbProjectVO">
|
|
SELECT
|
*
|
FROM SJZT_MD."tb_project" tb
|
where
|
tb."is_deleted" = 0
|
<if test="vo.cityCode != null and vo.cityCode != ''">
|
and tb."city_code" = #{vo.cityCode}
|
</if>
|
<if test="vo.countyCode != null and vo.countyCode != ''">
|
and tb."county_code" = #{vo.countyCode}
|
</if>
|
<if test="vo.isEstablishPlan != null and vo.isEstablishPlan !=''">
|
and tb."is_establish_plan" = #{vo.isEstablishPlan}
|
</if>
|
<if test="vo.isGovPurchase != null and vo.isGovPurchase != ''">
|
and tb."is_gov_purchase" = #{vo.isGovPurchase}
|
</if>
|
<if test="vo.contractDateQuery != null and vo.contractDateQuery != ''">
|
and tb."contract_date" = #{vo.contractDateQuery}
|
</if>
|
<if test="vo.startTime!=null and vo.startTime!=''">
|
and tb."check_date">= #{vo.startTime}
|
</if>
|
<if test="vo.endTime!=null and vo.endTime!=''">
|
and tb."check_date" <= #{vo.endTime}
|
</if>
|
order by CAST(city_code AS number) asc,CAST(county_code AS number) asc,CAST(guid AS number) desc
|
</select>
|
|
<resultMap id="dto" type="cn.gistack.sm.sjztmd.dto.TbProjectDTO">
|
<id property="guid" column="guid"/>
|
<result property="tbYear" column="tb_year"/>
|
<result property="cityCode" column="city_code"/>
|
<result property="cityName" column="city_name"/>
|
<result property="countyCode" column="county_code"/>
|
<result property="countyName" column="county_name"/>
|
<result property="other" column="other"/>
|
<result property="centerFund" column="center_fund"/>
|
<result property="localFund" column="local_fund"/>
|
<result property="isEstablishPlan" column="is_establish_plan"/>
|
<result property="planUrl" column="plan_url"/>
|
<result property="planFeedBackUrl" column="plan_feed_back_url"/>
|
<result property="isGovPurchase" column="is_gov_purchase"/>
|
<result property="purchaseWay" column="purchase_way"/>
|
<result property="govUrl" column="gov_url"/>
|
<result property="contractDate" column="contract_date"/>
|
<result property="contractUrl" column="contract_url"/>
|
<result property="checkDate" column="check_date"/>
|
<result property="planCheckDate" column="plan_check_date"/>
|
|
<result property="isCheck" column="is_check"/>
|
<result property="checkUrl" column="check_url"/>
|
|
|
<result column="create_user" property="createUser"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="update_user" property="updateUser"/>
|
|
<collection property="tbProjectScheduleList" ofType="cn.gistack.sm.sjztmd.entity.TbProjectSchedule">
|
<id property="guid" column="scheduleId"/>
|
<result property="year" column="year"/>
|
<result property="month" column="month"/>
|
<result property="actualFund" column="actual_fund"/>
|
</collection>
|
</resultMap>
|
|
|
|
|
<select id="getDetail" resultMap="dto">
|
SELECT
|
tb.*,
|
TPS."guid" as scheduleId,
|
TPS."year",
|
TPS."month",
|
TPS."actual_fund"
|
from sjzt_md."tb_project" tb
|
LEFT JOIN SJZT_MD."tb_project_schedule" TPS ON TPS."tb_project_id" = tb."guid"
|
where
|
tb."is_deleted" = 0
|
AND tb."guid" = #{id}
|
</select>
|
|
|
|
<select id="getStatisticsTable" resultType="cn.gistack.sm.sjztmd.statisticsVO.StatisticsTableProject">
|
SELECT
|
aab."guid" adCode,
|
aab."ad_name" adName,
|
aab."ad_grad" AS adGrad,
|
paab."guid" padCode,
|
paab."ad_name" padName,
|
tps.curMonthActualFund,
|
project.totalActualFund,
|
ifNull(resNum,0) resNum,
|
ifNull(bigNum,0) bigNum,
|
ifNull(midNum,0) midNum,
|
ifNull(smallOneNum,0) smallOneNum,
|
ifNull(smallTwoNum,0) smallTwoNum,
|
dykeLength,
|
levelOneLength,
|
levelTwoLength,
|
levelThreeLength,
|
levelFourLength,
|
levelFiveLength
|
FROM YWXT."att_ad_base" aab
|
left join (
|
SELECT
|
aab."guid",
|
aab."ad_name",
|
SUM(CASE WHEN arb."code" is not null then 1 else 0 end) as resNum ,
|
SUM(CASE WHEN (arb."eng_scal" = '大(1)型' or arb."eng_scal" = '大(2)型') then 1 else 0 end) as bigNum ,
|
SUM(CASE WHEN (arb."eng_scal" = '中型') then 1 else 0 end) as midNum ,
|
SUM(CASE WHEN (arb."eng_scal" = '小(1)型') then 1 else 0 end) as smallOneNum ,
|
SUM(CASE WHEN (arb."eng_scal" = '小(2)型') then 1 else 0 end) as smallTwoNum
|
FROM YWXT."att_ad_base" aab
|
LEFT JOIN
|
(
|
<include refid="selectResByRegion"/>
|
) arb ON ((arb.townCode = aab."guid")or(arb.countyCode = aab."guid") or (arb.cityCode = aab."guid") or (arb.provinceCode = aab."guid") )
|
right join sjzt_md."tb_res_general_investigation_state" trgis on trgis."res_guid" = arb."code"
|
<!--统计待审核和已审核的-->
|
and (trgis."check_state" = 1 or trgis."check_state" = 2)
|
<if test="params.tbYear != null and params.tbYear != ''">
|
and trgis."tb_year" = #{params.tbYear}
|
</if>
|
group by aab."guid",aab."ad_name"
|
)res on res."guid" = aab."guid"
|
left join (
|
SELECT
|
aab."guid",
|
aab."ad_name",
|
SUM(CASE WHEN trd."dyke_guid" is not null then trd.dangerLength else 0 END) as dykeLength,
|
SUM(CASE WHEN trd."dyke_level" = '1级' THEN trd.dangerLength ELSE 0 END) AS levelOneLength,
|
SUM(CASE WHEN trd."dyke_level" = '2级' THEN trd.dangerLength ELSE 0 END) AS levelTwoLength,
|
SUM(CASE WHEN trd."dyke_level" = '3级' THEN trd.dangerLength ELSE 0 END)AS levelThreeLength,
|
SUM(CASE WHEN trd."dyke_level" = '4级' THEN trd.dangerLength ELSE 0 END) AS levelFourLength,
|
SUM(CASE WHEN trd."dyke_level" = '5级' THEN trd.dangerLength ELSE 0 END) AS levelFiveLength
|
FROM YWXT."att_ad_base" aab
|
LEFT JOIN (
|
SELECT
|
trd."guid",
|
trd."dyke_length",
|
trd."dyke_level",
|
trd."dyke_guid",
|
trd.dangerLength,
|
county."guid" as countyCode,
|
city."guid" as cityCode,
|
province."guid" as provinceCode
|
FROM (
|
SELECT
|
tdis."guid",
|
tdis."dyke_guid",
|
trd."ad_code",
|
trd."dyke_level",
|
trd."dyke_length",
|
tdi.dangerLength
|
FROM SJZT_MD."tb_dyke_investigation_state" tdis
|
LEFT JOIN SJZT_MD."tb_res_dyke" trd on trd."guid" = tdis."dyke_guid"
|
LEFT JOIN (
|
SELECT
|
TEMP1."tb_state_id",
|
TEMP1."unit",
|
TEMP1.dangerLength/temp1.num as dangerLength
|
FROM (
|
SELECT
|
tdi."tb_state_id",
|
tdi."dyke_guid",
|
tdi."unit",
|
count(*) as num,
|
SUM(CASE WHEN (tdi."danger_length") THEN tdi."danger_length" ELSE 0 END) AS dangerLength
|
from sjzt_md."tb_dyke_investigation" tdi
|
where 1=1
|
<if test="params.tbYear != null and params.tbYear != ''">
|
AND tdi."tb_year" = #{params.tbYear}
|
</if>
|
group by tdi."tb_state_id",tdi."dyke_guid",tdi."unit"
|
)TEMP1
|
) tdi on tdi."tb_state_id" = tdis."guid"
|
<!--统计待审核和已审核的-->
|
where (tdis."check_state" = 1 or tdis."check_state" = 2)
|
) trd
|
LEFT JOIN YWXT."att_ad_base" county ON county."ad_code" = trd."ad_code"
|
LEFT JOIN YWXT."att_ad_base" city ON city."ad_code" = county."p_ad_code"
|
LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = city."p_ad_code"
|
)trd on ((trd.countyCode = aab."guid") or (trd.cityCode = aab."guid") or (trd.provinceCode = aab."guid"))
|
group by aab."guid",aab."ad_name"
|
)dyke on dyke."guid" = aab."guid"
|
left join (
|
SELECT
|
aab."guid",
|
aab."ad_name",
|
SUM(CASE WHEN tb."actual_fund" then tb."actual_fund" else 0 end) as totalActualFund
|
FROM YWXT."att_ad_base" aab
|
LEFT JOIN (
|
select
|
tb."city_code" cityCode,
|
tb."county_code" countyCode,
|
province."guid" provinceCode,
|
tps."actual_fund"
|
from sjzt_md."tb_project" tb
|
LEFT JOIN SJZT_MD."tb_project_schedule" tps on tps."tb_project_id" = tb."guid"
|
LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = tb."city_code"
|
)tb on ((tb.countyCode = aab."guid") or (tb.cityCode = aab."guid") or (tb.provinceCode = aab."guid"))
|
group by aab."guid",aab."ad_name"
|
) project on project."guid" = aab."guid"
|
left join (
|
SELECT
|
aab."guid",
|
aab."ad_name",
|
tb."actual_fund" curMonthActualFund
|
FROM YWXT."att_ad_base" aab
|
LEFT JOIN (
|
select
|
tb."city_code" cityCode,
|
tb."county_code" countyCode,
|
province."guid" provinceCode,
|
tps."actual_fund"
|
from sjzt_md."tb_project" tb
|
LEFT JOIN SJZT_MD."tb_project_schedule" tps on tps."tb_project_id" = tb."guid"
|
LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = tb."city_code"
|
where
|
1=1
|
<if test="params.tbYear != null and params.tbYear !=''">
|
AND tps."year" = #{params.tbYear}
|
</if>
|
<if test="params.tbMonth != null and params.tbMonth != ''">
|
and tps."month" = #{params.tbMonth}
|
</if>
|
)tb on ((tb.countyCode = aab."guid") or (tb.cityCode = aab."guid") or (tb.provinceCode = aab."guid"))
|
) tps on tps."guid" = aab."guid"
|
left join ywxt."att_ad_base" paab on paab."guid" = aab."p_ad_code"
|
where
|
1=1
|
<if test="params.adCode != null and params.adCode !=''">
|
AND aab."p_ad_code" = #{params.adCode}
|
</if>
|
</select>
|
<select id="getTbProjectInfo" resultType="cn.gistack.sm.sjztmd.entity.TbProject">
|
SELECT
|
*
|
FROM SJZT_MD."tb_project"
|
where 1=1
|
<if test="params.cityCode != null and params.cityCode !=''">
|
and "city_code" = #{params.cityCode}
|
</if>
|
<if test="params.countyCode != null and params.countyCode !=''">
|
and "county_code" = #{params.countyCode}
|
</if>
|
<if test="params.tbYear != null and params.tbYear !=''">
|
and "tb_year" = #{params.tbYear}
|
</if>
|
</select>
|
<select id="getStatisticsPie" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPrice">
|
SELECT
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
|
sum(
|
NVL ( b."actual_fund", 0 )) sumPay,
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
|
NVL ( b."actual_fund", 0 )) noPay
|
FROM
|
sjzt_md."tb_project" a
|
LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
|
WHERE 1=1
|
<if test="params.tbYear != null and params.tbYear !=''">
|
AND "year" = #{params.tbYear}
|
</if>
|
<if test="params.tbMonth != null and params.tbMonth !=''">
|
AND "month" = #{params.tbMonth}
|
</if>
|
) b ON a."guid" = b."tb_project_id"
|
</select>
|
<select id="getStatisticsPies" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPrice">
|
SELECT
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
|
sum(
|
NVL ( b."actual_fund", 0 )) sumPay,
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
|
NVL ( b."actual_fund", 0 )) noPay
|
FROM
|
sjzt_md."tb_project" a
|
LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
|
WHERE "check_state" = 3
|
<if test="params.tbYear != null and params.tbYear !=''">
|
AND "year" = #{params.tbYear}
|
</if>
|
<if test="params.tbMonth != null and params.tbMonth !=''">
|
AND "month" = #{params.tbMonth}
|
</if>
|
) b ON a."guid" = b."tb_project_id"
|
LEFT JOIN YWXT."att_ad_base" c ON ( a."city_code" = c."guid" )
|
OR ( a."county_code" = c."guid" )
|
WHERE
|
c."guid" = #{params.adCode}
|
</select>
|
<select id="getStatisticsPieBar" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPriceVO">
|
SELECT
|
c."ad_code" adCode,
|
c."ad_name" adName,
|
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
|
sum(
|
NVL ( b."actual_fund", 0 )) sumPay,
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
|
NVL ( b."actual_fund", 0 )) noPay
|
FROM
|
sjzt_md."tb_project" a
|
LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
|
WHERE "check_state" = 3
|
<if test="params.tbYear != null and params.tbYear !=''">
|
AND "year" = #{params.tbYear}
|
</if>
|
<if test="params.tbMonth != null and params.tbMonth !=''">
|
AND "month" = #{params.tbMonth}
|
</if>
|
) b ON a."guid" = b."tb_project_id"
|
RIGHT JOIN YWXT."att_ad_base" c on c."ad_code" = a."city_code"
|
where c."p_ad_code" = #{params.adCode}
|
GROUP BY
|
c."ad_code" ,
|
c."ad_name"
|
</select>
|
<select id="getStatisticsPieBars" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPriceVO">
|
SELECT
|
b."ad_name" adName,
|
b."ad_code" adCode,
|
a.sumPrice sumPrice,
|
a.noPay noPay,
|
a.sumPay sumPay
|
FROM
|
(
|
SELECT
|
a."county_code",
|
a."county_name",
|
a."city_code",
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
|
sum(
|
NVL ( b."actual_fund", 0 )) sumPay,
|
sum(
|
NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
|
NVL ( b."actual_fund", 0 )) noPay
|
FROM
|
sjzt_md."tb_project" a
|
LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
|
WHERE 1=1
|
<if test="params.tbYear != null and params.tbYear !=''">
|
AND "year" = #{params.tbYear}
|
</if>
|
<if test="params.tbMonth != null and params.tbMonth !=''">
|
AND "month" = #{params.tbMonth}
|
</if>
|
) b ON a."guid" = b."tb_project_id"
|
GROUP BY
|
a."county_code",
|
a."county_name",
|
a."city_code"
|
) a
|
RIGHT JOIN YWXT."att_ad_base" b ON ( b."guid" = a."city_code" )
|
OR ( b."guid" = a."county_code" )
|
WHERE
|
b."p_ad_code" = #{params.adCode}
|
</select>
|
<select id="getfill" resultType="cn.gistack.sm.sjztmd.vo.TbProjectIsfillVO">
|
select "isFil","end_time" endTime, "start_time" stratTime from SJZT_MD."tb_project_fill"
|
</select>
|
</mapper>
|