<?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.qianwen.smartman.modules.smis.mapper.ProductMapper">
|
|
<update id="removeBindCraft">
|
update blade_craft_routing set product_id = null where product_id
|
in
|
<foreach collection="ids" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
</update>
|
|
<select id="selectListByIds" resultType="com.qianwen.smartman.modules.smis.vo.ProductVO">
|
SELECT bp.*, bp2.code AS parentCode , bp2.name AS parentName ,bpt.name AS typeName FROM blade_product bp
|
left join blade_product bp2
|
on bp.parent_id =
|
bp2.id left join blade_product_type bpt on bp.type_id = bpt.id
|
<where>
|
bp.is_deleted = 0 AND
|
bp.id in
|
<foreach collection="ids" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
</where>
|
order by bp.${orderBy}
|
</select>
|
|
<select id="selectIdById" resultType="com.qianwen.smartman.modules.smis.entity.Product">
|
SELECT id FROM blade_product
|
<where>
|
is_deleted = 0 AND
|
id in
|
<foreach collection="param.ids" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
<if test="param.keyWord != null and param.keyWord != ''">
|
AND (code LIKE CONCAT(#{param.keyWord}, '%')
|
OR name LIKE CONCAT(#{param.keyWord}, '%') )
|
</if>
|
<if test="param.standardModel != null and param.standardModel != ''">
|
AND standard_model LIKE CONCAT(#{param.standardModel}, '%')
|
</if>
|
<if test="param.status != null ">
|
AND status = #{param.status}
|
</if>
|
<if test="param.typeIds != null and param.typeIds != '' ">
|
AND type_id in
|
<foreach collection="param.typeIds" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
</if>
|
order by ${param.orderBy}
|
</where>
|
|
</select>
|
|
<select id="getParentStatusCount" resultType="int">
|
select count(1) from blade_product where is_deleted = 0 and status = 1 and parent_id
|
in
|
<foreach collection="ids" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="getParentDetail" parameterType="long" resultType="com.qianwen.smartman.modules.smis.entity.Product">
|
SELECT id, parent_id, status
|
FROM `blade_product`
|
where id = (SELECT parent_id from blade_product where id = #{id})
|
</select>
|
<select id="selectListByParam" resultType="com.qianwen.smartman.modules.smis.vo.ProductVO">
|
SELECT bp.*, bp2.code AS parentCode , bp2.name AS parentName ,bpt.name AS typeName FROM blade_product bp
|
left join blade_product bp2
|
on bp.parent_id =
|
bp2.id left join blade_product_type bpt on bp.type_id = bpt.id
|
<where>
|
bp.is_deleted = 0
|
<if test="param.keyWord != null and param.keyWord != ''">
|
AND (bp.code LIKE CONCAT(#{param.keyWord}, '%')
|
OR bp.name LIKE CONCAT(#{param.keyWord}, '%') )
|
</if>
|
<if test="param.parentId != null">
|
AND bp.parent_id = #{param.parentId}
|
</if>
|
<if test="param.standardModel != null and param.standardModel != ''">
|
AND bp.standard_model LIKE CONCAT(#{param.standardModel}, '%')
|
</if>
|
<if test="param.status != null ">
|
AND bp.status = #{param.status}
|
</if>
|
<if test="param.typeIds != null and param.typeIds != '' ">
|
AND bp.type_id in
|
<foreach collection="param.typeIds" index="index" open="(" close=")" separator="," item="item">
|
#{item}
|
</foreach>
|
</if>
|
</where>
|
order by bp.create_time desc
|
</select>
|
|
<select id="notBandProduct" resultType="com.qianwen.smartman.modules.smis.entity.Product">
|
select id,
|
tenant_id,
|
code,
|
name,
|
parent_id,
|
type_id,
|
unit,
|
standard_model,
|
description,
|
documents,
|
create_user,
|
create_dept,
|
create_time,
|
update_user,
|
update_time,
|
status,
|
is_deleted
|
from blade_product bp
|
where not exists(select *
|
from blade_craft_routing bcr
|
where bcr.is_deleted = 0
|
and bcr.product_id = bp.id
|
and bcr.id != #{craftId})
|
and bp.is_deleted = 0;
|
</select>
|
|
<select id="exportProduct" resultType="com.qianwen.smartman.modules.smis.excel.ProductExcel">
|
select bp1.code,
|
bp1.name,
|
bp2.code parentId,
|
bpt.name typeName,
|
bp1.extend_field ,
|
bp1.unit,
|
bp1.standard_model,
|
bp1.description,
|
bp1.documents,
|
bp1.status,
|
bp1.extend_field
|
from blade_product bp1
|
left join blade_product bp2 on bp1.parent_id = bp2.id and bp2.is_deleted = 0
|
left join blade_product_type bpt on bp1.type_id = bpt.id and bpt.is_deleted = 0
|
where bp1.is_deleted = 0
|
<if test="ew!=null">
|
and ${ew.sqlSegment}
|
</if>
|
<if test="fieldSql != null and fieldSql != ''">
|
and ${fieldSql}
|
</if>
|
order by bp1.create_time desc,bp1.id desc ;
|
</select>
|
|
<select id="lazyTree" resultType="com.qianwen.smartman.modules.smis.vo.ProductEasyVO">
|
select bp1.id,
|
bp1.code,
|
bp1.name,
|
bp1.parent_id,
|
bp1.type_id,
|
bp1.unit,
|
bp1.standard_model,
|
bp1.description,
|
bp1.documents,
|
bp1.status,
|
bp1.extend_field,
|
bpt.name typeName
|
from blade_product bp1
|
left join blade_product_type bpt on bp1.type_id = bpt.id
|
where bp1.is_deleted = 0
|
<if test="ew!=null">
|
and ${ew.sqlSegment}
|
</if>
|
<if test="fieldSql != null and fieldSql != ''">
|
and ${fieldSql}
|
</if>
|
order by bp1.create_time desc,bp1.id desc ;
|
</select>
|
<select id="hasChild"
|
resultType="com.qianwen.smartman.modules.smis.dto.ProductCountDTO">
|
SELECT
|
parent_id AS productId,
|
count( parent_id ) AS count
|
FROM
|
blade_product
|
WHERE
|
is_deleted = 0
|
<if test="status == 1">
|
and status = 1
|
</if>
|
<if test="status == 0">
|
and status = 0
|
</if>
|
and parent_id IN
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
GROUP BY
|
parent_id
|
|
</select>
|
<select id="lazyTreeCount" resultType="java.lang.Integer">
|
select
|
count(1)
|
from blade_product bp1
|
left join blade_product_type bpt on bp1.type_id = bpt.id
|
where bp1.is_deleted = 0
|
<if test="ew!=null">
|
and ${ew.sqlSegment}
|
</if>
|
<if test="fieldSql != null and fieldSql != ''">
|
and ${fieldSql}
|
</if>
|
</select>
|
</mapper>
|