<?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.thhy.materials.modules.biz.concret.mapper.SysSteelRecordMapper">
|
<resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
|
<!--
|
WARNING - @mbg.generated
|
This element is automatically generated by MyBatis Generator, do not modify.
|
This element was generated on Thu Apr 06 09:40:33 CST 2023.
|
-->
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
<result column="steel_id" jdbcType="VARCHAR" property="steelId" />
|
<result column="stock_type" jdbcType="INTEGER" property="stockType" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="change_stock" jdbcType="DOUBLE" property="changeStock" />
|
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
|
<result column="factory_name" jdbcType="VARCHAR" property="factoryName" />
|
<result column="brand" jdbcType="VARCHAR" property="brand" />
|
<result column="line_code" jdbcType="VARCHAR" property="lineCode" />
|
<result column="pro_id" jdbcType="VARCHAR" property="proId" />
|
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
</resultMap>
|
|
<select id="steelSelectStock" parameterType="java.lang.String" resultType="java.lang.Double">
|
select stock from sys_steel where steel_id=#{steelId}
|
</select>
|
|
<update id="steelStockUpdate">
|
update sys_steel set
|
stock=#{stock}
|
where steel_id=#{steelId}
|
</update>
|
|
<insert id="recordInsert">
|
insert into sys_steel_record
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="steelId != null">
|
steel_id,
|
</if>
|
<if test="stockType != null">
|
stock_type,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="changeStock != null">
|
change_stock,
|
</if>
|
<if test="supplierId != null">
|
supplier_id,
|
</if>
|
<if test="factoryName != null">
|
factory_name,
|
</if>
|
<if test="brand != null">
|
brand,
|
</if>
|
<if test="lineCode != null">
|
line_code,
|
</if>
|
<if test="proId != null">
|
pro_id,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="companyId != null">
|
company_id,
|
</if>
|
<if test="carName != null">
|
car_name,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="steelId != null">
|
#{steelId,jdbcType=VARCHAR},
|
</if>
|
<if test="stockType != null">
|
#{stockType,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="changeStock != null">
|
#{changeStock,jdbcType=DOUBLE},
|
</if>
|
<if test="supplierId != null">
|
#{supplierId,jdbcType=VARCHAR},
|
</if>
|
<if test="factoryName != null">
|
#{factoryName,jdbcType=VARCHAR},
|
</if>
|
<if test="brand != null">
|
#{brand,jdbcType=VARCHAR},
|
</if>
|
<if test="lineCode != null">
|
#{lineCode,jdbcType=VARCHAR},
|
</if>
|
<if test="proId != null">
|
#{proId,jdbcType=VARCHAR},
|
</if>
|
<if test="createUser != null">
|
#{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="companyId != null">
|
#{companyId,jdbcType=VARCHAR},
|
</if>
|
<if test="carName != null">
|
#{carName,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
<select id="recordList" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
|
select ssr.id,
|
ssr.steel_id as steelId,
|
ssr.stock_type as stockType,
|
ssr.create_time as createTime,
|
ssr.change_stock as changeStock,
|
ssr.supplier_id as supplierId,
|
ssr.factory_name as factoryName,
|
ssr.brand as brand,
|
ssr.line_code as lineCode,
|
ssr.pro_id as proId,
|
ss.steel_name as steelName,
|
ss.steel_model steelModel,
|
ss.unit,
|
s2.supplier_name as supplierName,
|
su.real_name as realName,
|
sp.pro_name as proName,
|
ssr.car_name as carName
|
from sys_steel_record ssr
|
left join sys_steel ss on ssr.steel_id=ss.steel_id
|
left join sys_supplier s2 on ssr.supplier_id=s2.id
|
left join sys_users su on ssr.create_user=su.user_id
|
left join sys_project sp on ssr.pro_id=sp.pro_id
|
where ssr.is_use=1
|
<if test="stockType!=null and stockType!='' ">
|
and ssr.stock_type=#{stockType}
|
</if>
|
<if test="steelId!=null and steelId!='' ">
|
and ssr.steel_id=#{steelId}
|
</if>
|
<if test="steelName!=null and steelName!='' ">
|
and ss.steel_name like concat('%',#{steelName},'%')
|
</if>
|
<if test="steelModel!=null and steelModel!='' ">
|
and ss.steel_model like concat('%',#{steelModel},'%')
|
</if>
|
<if test="supplierId!=null and supplierId!='' ">
|
and ssr.supplier_id=#{supplierId}
|
</if>
|
<if test="factoryName!=null and factoryName!='' ">
|
and ssr.factory_name like concat('%',#{factoryName},'%')
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and ssr.create_time between #{strTime} and #{endTime}
|
</if>
|
<if test="companyId!=null and companyId!='' ">
|
and ss.company_id=#{companyId}
|
</if>
|
order by ssr.create_time desc
|
</select>
|
<select id="recordThingJsList" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
|
select ssr.id,
|
ssr.steel_id as steelId,
|
ssr.stock_type as stockType,
|
ssr.create_time as createTime,
|
ssr.change_stock as changeStock,
|
ssr.supplier_id as supplierId,
|
ssr.factory_name as factoryName,
|
ssr.brand as brand,
|
ssr.line_code as lineCode,
|
ssr.pro_id as proId,
|
ss.steel_name as steelName,
|
ss.steel_model steelModel,
|
ss.unit,
|
s2.supplier_name as supplierName,
|
su.real_name as realName,
|
sp.pro_name as proName
|
from sys_steel_record ssr
|
left join sys_steel ss on ssr.steel_id=ss.steel_id
|
left join sys_supplier s2 on ssr.supplier_id=s2.id
|
left join sys_users su on ssr.create_user=su.user_id
|
left join sys_project sp on ssr.pro_id=sp.pro_id
|
where ssr.is_use=1
|
and ssr.stock_type=2
|
and ss.company_id=#{companyId}
|
order by ssr.create_time desc limit 0,10
|
</select>
|
<select id="recordInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteelRecord">
|
select
|
ssr.id,
|
ssr.steel_id as steelId,
|
ssr.stock_type as stockType,
|
ssr.create_time as createTime,
|
ssr.change_stock as changeStock,
|
ssr.supplier_id as supplierId,
|
ssr.factory_name as factoryName,
|
ssr.brand as brand,
|
ssr.line_code as lineCode,
|
ssr.pro_id as proId,
|
ss.steel_name as steelName,
|
ss.steel_model steelModel,
|
ss.unit,
|
s2.supplier_name as supplierName,
|
su.real_name as realName
|
from sys_steel_record ssr
|
left join sys_steel ss on ssr.steel_id=ss.steel_id
|
left join sys_supplier s2 on ssr.supplier_id=s2.id
|
left join sys_users su on ssr.create_user=su.user_id
|
where ssr.is_use=1 and ssr.id=#{id}
|
</select>
|
|
<update id="recordDel" >
|
update sys_steel_record set
|
is_use=2
|
where id=#{id}
|
</update>
|
<update id="updateStockSteelId" >
|
update sys_steel set
|
stock=#{stocks}
|
where steel_id=#{steelId}
|
</update>
|
<select id="supplierPull" parameterType="java.lang.String" resultType="java.lang.String">
|
select ss.supplier_name from sys_supplier ss
|
left join sys_supplier_pro ssp on ss.id=ssp.supplier_id
|
left join sys_project sp on sp.pro_id=ssp.pro_id
|
where ss.is_use=1
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
group by ssp.supplier_id,ss.supplier_name
|
</select>
|
|
|
<select id="supplierIdSelect" parameterType="java.lang.String" resultType="java.lang.String">
|
select id from sys_supplier where is_use=1
|
and supplier_name=#{supplierName}
|
</select>
|
<select id="steelNameAndSteelModelSelectSteelId"
|
resultType="com.thhy.materials.modules.biz.concret.entity.SysSteel">
|
select
|
steel_id as steelId,
|
steel_name as steelName,
|
steel_model as steelModel,
|
unit as unit,
|
stock as stock,
|
create_time as createTime,
|
create_user as createUser,
|
is_use as isUse
|
from sys_steel where is_use=1
|
and steel_name=#{steelName} and steel_model=#{steelModel}
|
</select>
|
|
<select id="recordStatisticsDay" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
|
SELECT
|
ss.steel_id as steelId,
|
ss.steel_name as steelName,
|
ss.steel_model as steelModel,
|
DATE( ssr.create_time ) as getDate,
|
sum( ssr.change_stock ) as changeStock
|
FROM
|
sys_steel_record ssr
|
LEFT JOIN sys_steel ss ON ssr.steel_id = ss.steel_id
|
WHERE
|
ssr.stock_type = 2 and ssr.is_use=1
|
<if test="steelId!=null and steelId!='' ">
|
and ssr.steel_id=#{steelId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and DATE( ssr.create_time ) between #{strTime} and #{endTime}
|
</if>
|
<if test="companyId!=null and companyId!='' ">
|
and ss.company_id=#{companyId}
|
</if>
|
GROUP BY
|
DATE( ssr.create_time ),
|
ssr.steel_id
|
</select>
|
<select id="recordStatisticsMonth" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
|
SELECT
|
ssr.steel_id AS steelId,
|
ss.steel_name AS steelName,
|
ss.steel_model AS steelModel,
|
CONCAT(
|
CONCAT( YEAR ( ssr.create_time ), '-' ),
|
IF
|
( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) AS getDate,
|
SUM( ssr.change_stock ) AS changeStock
|
FROM
|
sys_steel_record ssr
|
LEFT JOIN sys_steel ss ON ssr.steel_id = ss.steel_id
|
WHERE
|
ssr.stock_type = 2 and ssr.is_use=1
|
<if test="steelId!=null and steelId!='' ">
|
and ssr.steel_id=#{steelId}
|
</if>
|
<if test="companyId!=null and companyId!='' ">
|
and ss.company_id=#{companyId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
AND CONCAT(
|
CONCAT( YEAR ( ssr.create_time ), '-' ),
|
IF
|
( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) BETWEEN #{strTime}
|
AND #{endTime}
|
</if>
|
GROUP BY
|
ssr.steel_id,
|
CONCAT(
|
CONCAT( YEAR ( ssr.create_time ), '-' ),
|
IF
|
( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) ))
|
</select>
|
<select id="recordSumDay" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
|
SELECT
|
ss.steel_id as steelId,
|
ss.steel_name as steelName,
|
ss.steel_model as steelModel,
|
SUM( ssr.change_stock ) as changeStock
|
FROM
|
sys_steel ss
|
JOIN sys_steel_record ssr ON ss.steel_id = ssr.steel_id
|
WHERE
|
ssr.stock_type = 2
|
AND ssr.is_use = 1
|
<if test="companyId!=null and companyId!='' ">
|
and ss.company_id=#{companyId}
|
</if>
|
<if test="steelId!=null and steelId!='' ">
|
and ss.steel_id=#{steelId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and DATE( ssr.create_time ) between #{strTime} and #{endTime}
|
</if>
|
GROUP BY
|
ss.steel_id
|
</select>
|
<select id="recordSumMonth" resultType="com.thhy.materials.modules.biz.concret.entity.dto.SteelStatisticsDto">
|
SELECT
|
ss.steel_id as steelId,
|
ss.steel_name as steelName,
|
ss.steel_model as steelModel,
|
SUM( ssr.change_stock ) as changeStock
|
FROM
|
sys_steel ss
|
JOIN sys_steel_record ssr ON ss.steel_id = ssr.steel_id
|
WHERE
|
ssr.stock_type = 2
|
AND ssr.is_use = 1
|
<if test="companyId!=null and companyId!='' ">
|
and ss.company_id=#{companyId}
|
</if>
|
<if test="steelId!=null and steelId!='' ">
|
and ss.steel_id=#{steelId}
|
</if>
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
AND CONCAT(
|
CONCAT( YEAR ( ssr.create_time ), '-' ),
|
IF
|
( MONTH ( ssr.create_time )> 9, MONTH ( ssr.create_time ), CONCAT( '0', MONTH ( ssr.create_time )) )) BETWEEN #{strTime}
|
AND #{endTime}
|
</if>
|
GROUP BY
|
ss.steel_id
|
</select>
|
<select id="steelPull" resultType="com.thhy.materials.modules.biz.concret.entity.SysSteel">
|
select steel_id as steelId,steel_name as steelName,
|
steel_model as steelModel,unit
|
from sys_steel where is_use=1
|
<if test="companyId!=null and companyId!='' ">
|
and company_id=#{companyId}
|
</if>
|
<if test="steelId!=null and steelId!='' ">
|
and steel_id=#{steelId}
|
</if>
|
</select>
|
|
</mapper>
|