You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
397 lines
16 KiB
397 lines
16 KiB
<?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.ccsens.pims.persist.dao.ProductDao">
|
|
|
|
<resultMap id="productInfo" type="com.ccsens.pims.bean.vo.CompanyVo$ProductType">
|
|
<id column="productType" property="productType"/>
|
|
<result column="productTypeName" property="productTypeName"/>
|
|
<collection property="productList" ofType="com.ccsens.pims.bean.vo.CompanyVo$ProductInfo">
|
|
<id column="productId" property="productId"/>
|
|
<result column="productName" property="productName"/>
|
|
<result column="pricing" property="pricing"/>
|
|
<result column="priceUnits" property="priceUnits"/>
|
|
<result column="grossMargin" property="grossMargin"/>
|
|
<result column="significanceSort" property="significanceSort"/>
|
|
<result column="description" property="description"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="productIncomeAll" type="com.ccsens.pims.bean.vo.CompanyVo$ProductIncomeType">
|
|
<id column="productType" property="productType"/>
|
|
<result column="productTypeName" property="productTypeName"/>
|
|
<collection property="productIncomeAllList" ofType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncomeAll">
|
|
<id column="productId" property="productId"/>
|
|
<result column="productName" property="productName"/>
|
|
<collection property="productIncomeList" ofType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome">
|
|
<id column="incomeId" property="incomeId"/>
|
|
<result column="month" property="month"/>
|
|
<result column="predictIncome" property="predictIncome"/>
|
|
<result column="realIncome" property="realIncome"/>
|
|
</collection>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="queryMonthFlow" type="com.ccsens.pims.bean.vo.ProductVo$MoneyFlowType">
|
|
<id column="moneyFlowType" property="moneyFlowType"/>
|
|
<result column="moneyFlowName" property="moneyFlowName"/>
|
|
<result column="moneyType" property="moneyType"/>
|
|
<collection property="predictMoneyFlow" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="month" property="month"/>
|
|
<result column="predictFlowLong" property="num"/>
|
|
</collection>
|
|
<collection property="realMoneyFlow" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="month" property="month"/>
|
|
<result column="realFlowLong" property="num"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="queryIncome" type="com.ccsens.pims.bean.vo.ProductVo$IncomeType">
|
|
<id column="incomeType" property="incomeType"/>
|
|
<result column="incomeName" property="incomeName"/>
|
|
<collection property="predictIncome" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="month" property="month"/>
|
|
<result column="predictIncome" property="num"/>
|
|
</collection>
|
|
<collection property="realIncome" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="month" property="month"/>
|
|
<result column="realIncome" property="num"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="queryProductIncomeMonth" type="com.ccsens.pims.bean.vo.ProductVo$ProductInfo">
|
|
<id column="productId" property="productId"/>
|
|
<result column="productName" property="productName"/>
|
|
<collection property="predictIncome" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="monthTime" property="month"/>
|
|
<result column="predictIncome" property="num"/>
|
|
</collection>
|
|
<collection property="realIncome" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="monthTime" property="month"/>
|
|
<result column="realIncome" property="num"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="getTotalCost" type="com.ccsens.pims.bean.vo.ProductVo$ProductCost">
|
|
<id column="costTypeName" property="costTypeName"/>
|
|
<collection property="predictCost" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="monthTime" property="month"/>
|
|
<result column="predictCost" property="num"/>
|
|
</collection>
|
|
<collection property="realCost" ofType="com.ccsens.pims.bean.vo.ProductVo$MonthNum">
|
|
<id column="monthTime" property="month"/>
|
|
<result column="realCost" property="num"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="queryMoneyFlowExcel" type="com.ccsens.pims.bean.vo.CompanyVo$MoneyFlowType">
|
|
<id column="moneyFlowType" property="moneyFlowType"/>
|
|
<result column="moneyFlowName" property="moneyFlowName"/>
|
|
<result column="moneyType" property="moneyType"/>
|
|
<collection property="moneyFlowList" ofType="com.ccsens.pims.bean.vo.CompanyVo$MoneyFlow">
|
|
<id column="moneyFlowLogId" property="moneyFlowLogId"/>
|
|
<result column="month" property="month"/>
|
|
<result column="predictMoneyFlow" property="predictMoneyFlow"/>
|
|
<result column="realMoneyFlow" property="realMoneyFlow"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="queryIncomeExcel" type="com.ccsens.pims.bean.vo.CompanyVo$IncomeType">
|
|
<id column="incomeType" property="incomeType"/>
|
|
<result column="incomeName" property="incomeName"/>
|
|
<collection property="incomeMonthList" ofType="com.ccsens.pims.bean.vo.CompanyVo$IncomeMonth">
|
|
<id column="incomeId" property="incomeId"/>
|
|
<result column="month" property="month"/>
|
|
<result column="predictIncome" property="predictIncome"/>
|
|
<result column="realIncome" property="realIncome"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="getCostProductExcel" type="com.ccsens.pims.bean.vo.CompanyVo$FirstCostType">
|
|
<id column="fCostId" property="fCostId"/>
|
|
<result column="fCostName" property="fCostName"/>
|
|
<collection property="costTypeList" ofType="com.ccsens.pims.bean.vo.CompanyVo$CostType">
|
|
<id column="costId" property="costId"/>
|
|
<result column="costName" property="costName"/>
|
|
<collection property="costMonthList" ofType="com.ccsens.pims.bean.vo.CompanyVo$CostMonth">
|
|
<id column="month" property="month"/>
|
|
<result column="predictCost" property="predictCost"/>
|
|
<result column="realCost" property="realCost"/>
|
|
</collection>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
|
|
<select id="getCostOtherExcel" parameterType="java.util.Map" resultMap="getCostProductExcel">
|
|
SELECT
|
|
t.id as fCostId,
|
|
t.`name` as fCostName,
|
|
a.tId as costId,
|
|
a.tName as costName,
|
|
a.`month` as `month`,
|
|
a.predictCost/100 as predictCost,
|
|
a.realCost/100 as realCost
|
|
FROM
|
|
t_cost_type t
|
|
LEFT JOIN
|
|
(
|
|
SELECT
|
|
ct.parent_id as parentId,
|
|
ct.id as tId,
|
|
ct.`name` as tName,
|
|
l.month_time as `month`,
|
|
l.predict_cost as predictCost,
|
|
l.real_cost as realCost
|
|
FROM
|
|
t_cost_type ct LEFT JOIN t_cost_log l on ct.id = l.cost_type_id
|
|
WHERE
|
|
ct.rec_status = 0
|
|
AND
|
|
(l.rec_status = 0 or l.rec_status is null)
|
|
AND
|
|
l.product_cost = 0
|
|
)a on t.id = a.parentId
|
|
WHERE
|
|
t.rec_status = 0
|
|
and
|
|
t.`level` = 0
|
|
AND
|
|
t.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="getCostProductExcel" parameterType="java.util.Map" resultMap="getCostProductExcel">
|
|
SELECT
|
|
t.id as fCostId,
|
|
t.`name` as fCostName,
|
|
p.id as costId,
|
|
p.`name` as costName,
|
|
l.month_time as `month`,
|
|
l.predict_cost/100 as predictCost,
|
|
l.real_cost/100 as realCost
|
|
FROM
|
|
t_product_type t LEFT JOIN t_product p on p.product_type_id = t.id
|
|
LEFT JOIN t_cost_log l on l.cost_type_id = p.id
|
|
WHERE
|
|
t.rec_status = 0
|
|
AND
|
|
p.rec_status = 0
|
|
AND
|
|
l.product_cost = 1
|
|
and
|
|
(l.rec_status = 0 or l.rec_status is null)
|
|
AND
|
|
t.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="queryIncomeExcel" parameterType="java.util.Map" resultMap="queryIncomeExcel">
|
|
SELECT
|
|
s.id as incomeType,
|
|
s.`name` as incomeName,
|
|
l.id as incomeId,
|
|
l.month_time as `month`,
|
|
l.predict_money/100 as predictIncome,
|
|
l.real_money/100 as realIncome
|
|
FROM
|
|
t_income_statements s LEFT JOIN t_income_statements_log l on l.income_statements_id = s.id
|
|
WHERE
|
|
s.rec_status = 0
|
|
AND
|
|
l.rec_status = 0
|
|
AND
|
|
s.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="queryMoneyFlowExcel" parameterType="java.util.Map" resultMap="queryMoneyFlowExcel">
|
|
SELECT
|
|
f.id as moneyFlowType,
|
|
f.`name` as moneyFlowName,
|
|
f.money_type as moneyType,
|
|
l.id as moneyFlowLogId,
|
|
l.month_time as `month`,
|
|
l.predict_money/100 as predictMoneyFlow,
|
|
l.real_money/100 as realMoneyFlow
|
|
FROM
|
|
t_money_flow f LEFT JOIN t_money_flow_log l on l.money_flow_id = f.id
|
|
WHERE
|
|
f.rec_status = 0
|
|
AND
|
|
l.rec_status = 0
|
|
AND
|
|
f.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="getTotalCost" parameterType="java.util.Map" resultMap="getTotalCost">
|
|
SELECT
|
|
t.`name` as costTypeName,
|
|
a.predict_cost/100 as predictCost,
|
|
a.real_cost/100 as realCost,
|
|
a.month_time as monthTime
|
|
FROM
|
|
t_cost_type t LEFT JOIN
|
|
(
|
|
SELECT
|
|
ct.parent_id as parent_id,
|
|
cl.month_time as month_time,
|
|
sum(cl.real_cost) as real_cost,
|
|
sum(cl.predict_cost) as predict_cost
|
|
FROM
|
|
`t_cost_type` ct LEFT JOIN t_cost_log cl on ct.id = cl.cost_type_id
|
|
WHERE
|
|
ct.rec_status = 0
|
|
and
|
|
(cl.rec_status = 0 or cl.rec_status is null)
|
|
and
|
|
cl.product_cost = 0
|
|
GROUP BY ct.parent_id,cl.month_time
|
|
)a on t.id = a.parent_id
|
|
WHERE
|
|
t.parent_id = 0
|
|
and
|
|
t.project_id = #{projectId}
|
|
and
|
|
t.rec_status = 0
|
|
ORDER BY a.month_time
|
|
</select>
|
|
|
|
<select id="queryProductInfo" parameterType="java.util.Map" resultMap="productInfo">
|
|
SELECT
|
|
pt.id as productType,
|
|
pt.`name` as productTypeName,
|
|
p.id as productId,
|
|
p.`name` as productName,
|
|
p.pricing/100 as pricing,
|
|
p.price_units as priceUnits,
|
|
p.gross_margin as grossMargin,
|
|
p.significance_sort as significanceSort,
|
|
p.description as description
|
|
FROM
|
|
t_product_type pt LEFT JOIN t_product p on pt.id = p.product_type_id
|
|
WHERE
|
|
pt.rec_status = 0
|
|
AND
|
|
p.rec_status = 0
|
|
AND
|
|
pt.project_id = #{projectId}
|
|
ORDER BY p.gross_margin DESC
|
|
</select>
|
|
|
|
<select id="getProductIncome" parameterType="java.util.Map" resultType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncome">
|
|
select
|
|
month_time as `month`,
|
|
predict_income/100 as predictIncome,
|
|
real_income/100 as realIncome
|
|
from
|
|
t_product_income
|
|
where
|
|
product_id = #{productId}
|
|
</select>
|
|
|
|
<select id="queryProductIncome" parameterType="java.util.Map" resultMap="productIncomeAll">
|
|
select
|
|
pt.id as productType,
|
|
pt.`name` as productTypeName,
|
|
p.id as productId,
|
|
p.`name` as productName,
|
|
pi.id as incomeId,
|
|
pi.month_time as `month`,
|
|
pi.predict_income/100 as predictIncome,
|
|
pi.real_income/100 as realIncome
|
|
from
|
|
t_product_type pt LEFT JOIN t_product p on pt.id = p.product_type_id Left join t_product_income pi on p.id = pi.product_id
|
|
where
|
|
pt.rec_status = 0
|
|
and
|
|
(pi.rec_status = 0 or pi.rec_status is null)
|
|
AND
|
|
p.rec_status = 0
|
|
and
|
|
pt.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="getTotalIncome" parameterType="java.util.Map" resultType="com.ccsens.pims.bean.vo.CompanyVo$TotalIncome">
|
|
select
|
|
sum(pt.predict_income) as predictTotal,
|
|
sum(pt.real_income) as realTotal
|
|
from
|
|
t_product p Left join t_product_income pt on p.id = pt.product_id
|
|
where
|
|
pt.rec_status = 0
|
|
AND
|
|
p.rec_status = 0
|
|
and
|
|
p.project_id = #{projectId}
|
|
|
|
</select>
|
|
|
|
<select id="queryProductIncomeProportion" parameterType="java.util.Map" resultType="com.ccsens.pims.bean.vo.CompanyVo$ProductIncomeProportion">
|
|
select
|
|
pt.month_time as `month`,
|
|
sum(pt.predict_income) as predictTotal,
|
|
sum(pt.real_income) as realTotal
|
|
from
|
|
t_product p Left join t_product_income pt on p.id = pt.product_id
|
|
where
|
|
pt.rec_status = 0
|
|
AND
|
|
p.rec_status = 0
|
|
and
|
|
p.project_id = #{projectId}
|
|
and
|
|
pt.year_income = #{year}
|
|
group by pt.month_time
|
|
</select>
|
|
|
|
<select id="queryMonthFlow" parameterType="java.util.Map" resultMap="queryMonthFlow">
|
|
SELECT
|
|
mf.id as moneyFlowType,
|
|
mf.`name` as moneyFlowName,
|
|
mf.money_type as moneyType,
|
|
l.id as MoneyFlowLogId,
|
|
l.month_time as `month`,
|
|
if(mf.money_type = 0,l.predict_money/100,(0-l.predict_money)/100) as predictFlowLong,
|
|
if(mf.money_type = 0,l.real_money/100,(0-l.real_money)/100) as realFlowLong
|
|
from
|
|
t_money_flow mf LEFT JOIN t_money_flow_log l on mf.id = l.money_flow_id
|
|
WHERE
|
|
mf.rec_status = 0
|
|
and
|
|
l.rec_status = 0
|
|
and
|
|
mf.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="queryIncome" parameterType="java.util.Map" resultMap="queryIncome">
|
|
SELECT
|
|
s.id as incomeType,
|
|
s.`name` as incomeName,
|
|
l.id as incomeId,
|
|
l.month_time as `month`,
|
|
l.predict_money/100 as `predictIncome`,
|
|
l.real_money/100 as `realIncome`
|
|
from
|
|
t_income_statements s LEFT JOIN t_income_statements_log l on s.id = l.income_statements_id
|
|
WHERE
|
|
s.rec_status = 0
|
|
and
|
|
l.rec_status = 0
|
|
and
|
|
s.project_id = #{projectId}
|
|
</select>
|
|
|
|
<select id="queryProductIncomeMonth" parameterType="java.util.Map" resultMap="queryProductIncomeMonth">
|
|
SELECT
|
|
p.id as productId,
|
|
p.`name` as productName,
|
|
i.predict_income/100 as predictIncome,
|
|
i.real_income/100 as realIncome,
|
|
i.month_time as monthTime
|
|
FROM
|
|
t_product p LEFT JOIN t_product_income i on i.product_id = p.id
|
|
WHERE
|
|
(i.rec_status = 0 or i.rec_status is null)
|
|
AND
|
|
p.rec_status = 0
|
|
AND
|
|
p.project_id = #{projectId}
|
|
</select>
|
|
|
|
</mapper>
|