341 lines
18 KiB
XML
341 lines
18 KiB
XML
<?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.xdadan.erp.emis.mapper.EmisTransPlanRuleMapper">
|
|
|
|
<resultMap type="EmisTransPlanRule" id="EmisTransPlanRuleResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
|
|
<result property="id" column="id" />
|
|
<result property="lineCode" column="line_code" />
|
|
<result property="lineName" column="line_name" />
|
|
<result property="productType" column="product_type" />
|
|
<result property="startSiteCode" column="start_site_code" />
|
|
<result property="startSiteName" column="start_site_name" />
|
|
<result property="nextSiteCode" column="next_site_code" />
|
|
<result property="nextSiteName" column="next_site_name" />
|
|
<result property="manager" column="manager" />
|
|
<result property="transManager" column="trans_manager" />
|
|
<result property="supplierCode" column="supplier_code" />
|
|
<result property="startDate" column="start_date" />
|
|
<result property="endDate" column="end_date" />
|
|
<result property="supplierName" column="supplier_name" />
|
|
<result property="productTypeName" column="product_type_name" />
|
|
</resultMap>
|
|
|
|
<sql id="selectEmisTransPlanRuleVo">
|
|
select r.id, r.line_code, r.product_type, r.start_site_code,
|
|
s1.site_name as start_site_name, r.next_site_code, s2.site_name as next_site_name,
|
|
r.manager, r.supplier_code, r.start_date, r.end_date, r.remark,
|
|
r.del_flag, r.create_by, r.create_time, r.update_by, r.update_time, r.create_site, r.update_site,
|
|
l.line_name,l.trans_manager,
|
|
(SELECT GROUP_CONCAT(s.name)
|
|
FROM emis_supplier s
|
|
WHERE FIND_IN_SET(s.code, r.supplier_code)
|
|
AND s.del_flag = '0') as supplier_name,
|
|
(SELECT GROUP_CONCAT(p.prod_name)
|
|
FROM emis_trans_product p
|
|
WHERE FIND_IN_SET(p.prod_code, r.product_type)
|
|
AND p.del_flag = '0') as product_type_name
|
|
from emis_trans_plan_rule r
|
|
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
|
|
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
|
|
left join emis_trans_line l on r.line_code = l.line_code and l.del_flag='0'
|
|
</sql>
|
|
|
|
<select id="selectEmisTransPlanRuleList" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
|
|
<include refid="selectEmisTransPlanRuleVo"/>
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="lineCode != null and lineCode != ''"> and r.line_code = #{lineCode}</if>
|
|
<if test="productType != null and productType != ''"> and ( FIND_IN_SET(#{productType},r.product_type) )</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''"> and r.start_site_code = #{startSiteCode}</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''"> and r.next_site_code = #{nextSiteCode}</if>
|
|
<if test="manager != null and manager != ''"> and r.manager = #{manager}</if>
|
|
<if test="supplierCode != null and supplierCode != ''"> and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
|
|
<if test="startDate != null"> and r.start_date = #{startDate}</if>
|
|
<if test="endDate != null"> and r.end_date = #{endDate}</if>
|
|
<if test="transManager != null and transManager != ''">
|
|
AND l.trans_manager like concat('%', #{transManager}, '%')
|
|
</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="checkTransPlanRule" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
|
|
select r.*
|
|
from emis_trans_plan_rule r
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="lineCode != null and lineCode != ''"> and r.line_code = #{lineCode}</if>
|
|
<if test="productType != null and productType != ''"> and ( FIND_IN_SET(#{productType},r.product_type) )</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''"> and r.start_site_code = #{startSiteCode}</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''"> and r.next_site_code = #{nextSiteCode}</if>
|
|
<if test="manager != null and manager != ''"> and r.manager = #{manager}</if>
|
|
<if test="supplierCode != null and supplierCode != ''"> and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
|
|
<if test="startDate != null"> and r.start_date = #{startDate}</if>
|
|
<if test="endDate != null"> and r.end_date = #{endDate}</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="selectRulesForAllScan" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
|
|
select r.id, r.line_code, r.product_type, r.start_site_code,r.next_site_code, s1.site_name as start_site_name,
|
|
s2.site_name as next_site_name,
|
|
r.manager, r.supplier_code, r.start_date, r.end_date, (SELECT GROUP_CONCAT(s.name)
|
|
FROM emis_supplier s
|
|
WHERE FIND_IN_SET(s.code, r.supplier_code)
|
|
AND s.del_flag = '0') as supplier_name
|
|
from emis_trans_plan_rule r
|
|
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
|
|
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
|
|
<if test="productType != null and productType != ''">and ( FIND_IN_SET(#{productType},r.product_type) )
|
|
</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
|
|
<if test="manager != null and manager != ''">and r.manager = #{manager}</if>
|
|
<if test="supplierCode != null and supplierCode != ''">and ( FIND_IN_SET(#{supplierCode},r.supplier_code)
|
|
)
|
|
</if>
|
|
<if test="startDate != null">and r.start_date = #{startDate}</if>
|
|
<if test="endDate != null">and r.end_date = #{endDate}</if>
|
|
<if test="transManager != null and transManager != ''">
|
|
AND l.trans_manager like concat('%', #{transManager}, '%')
|
|
</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="selectEmisTransPlanRuleByLineCodes" parameterType="list" resultMap="EmisTransPlanRuleResult">
|
|
select r.id, r.line_code, r.product_type, r.start_site_code,r.next_site_code, s1.site_name as start_site_name,
|
|
s2.site_name as next_site_name,
|
|
r.manager, r.supplier_code, r.start_date, r.end_date, (SELECT GROUP_CONCAT(s.name)
|
|
FROM emis_supplier s
|
|
WHERE FIND_IN_SET(s.code, r.supplier_code)
|
|
AND s.del_flag = '0') as supplier_name
|
|
from emis_trans_plan_rule r
|
|
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
|
|
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
|
|
<where>
|
|
r.del_flag = '0'
|
|
AND r.line_code in
|
|
<foreach item="lineCode" collection="lineCodes" open="(" separator="," close=")">
|
|
#{lineCode}
|
|
</foreach>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="checkDuplicate" parameterType="EmisTransPlanRule" resultMap="EmisTransPlanRuleResult">
|
|
<include refid="selectEmisTransPlanRuleVo"/>
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
|
|
<if test="productType != null and productType != ''">and r.product_type=#{productType}</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
|
|
<if test="supplierCode != null and supplierCode != ''">and r.supplier_code=#{supplierCode}</if>
|
|
</where>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="selectEmisTransPlanRuleById" parameterType="Long" resultMap="EmisTransPlanRuleResult">
|
|
<include refid="selectEmisTransPlanRuleVo"/>
|
|
where r.id = #{id} and r.del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectSupplierNamesByCodes" parameterType="String" resultType="String">
|
|
SELECT GROUP_CONCAT(s.name)
|
|
FROM emis_supplier s
|
|
WHERE FIND_IN_SET(s.code, #{supplierCodes}) AND s.del_flag = 0
|
|
</select>
|
|
|
|
<select id="selectProductTypeNamesByCodes" parameterType="String" resultType="String">
|
|
SELECT GROUP_CONCAT(s.prod_name)
|
|
FROM emis_trans_product s
|
|
WHERE FIND_IN_SET(s.prod_code, #{productType}) AND s.del_flag = 0
|
|
</select>
|
|
|
|
<insert id="insertEmisTransPlanRule" parameterType="EmisTransPlanRule" useGeneratedKeys="true" keyProperty="id">
|
|
insert into emis_trans_plan_rule
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="lineCode != null and lineCode != ''">line_code,</if>
|
|
<if test="productType != null">product_type,</if>
|
|
<if test="startSiteCode != null">start_site_code,</if>
|
|
<if test="nextSiteCode != null">next_site_code,</if>
|
|
<if test="manager != null">manager,</if>
|
|
<if test="supplierCode != null">supplier_code,</if>
|
|
<if test="startDate != null">start_date,</if>
|
|
<if test="endDate != null">end_date,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="createSite != null">create_site,</if>
|
|
<if test="updateSite != null">update_site,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="lineCode != null and lineCode != ''">#{lineCode},</if>
|
|
<if test="productType != null">#{productType},</if>
|
|
<if test="startSiteCode != null">#{startSiteCode},</if>
|
|
<if test="nextSiteCode != null">#{nextSiteCode},</if>
|
|
<if test="manager != null">#{manager},</if>
|
|
<if test="supplierCode != null">#{supplierCode},</if>
|
|
<if test="startDate != null">#{startDate},</if>
|
|
<if test="endDate != null">#{endDate},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="createSite != null">#{createSite},</if>
|
|
<if test="updateSite != null">#{updateSite},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEmisTransPlanRule" parameterType="EmisTransPlanRule">
|
|
update emis_trans_plan_rule
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="lineCode != null and lineCode != ''">line_code = #{lineCode},</if>
|
|
<if test="productType != null and productType != ''">product_type = #{productType},</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''">start_site_code = #{startSiteCode},</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code = #{nextSiteCode},</if>
|
|
<if test="manager != null and manager != ''">manager = #{manager},</if>
|
|
<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
|
|
<if test="startDate != null">start_date = #{startDate},</if>
|
|
<if test="endDate != null">end_date = #{endDate},</if>
|
|
<if test="remark != null ">remark = #{remark},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="createSite != null">create_site = #{createSite},</if>
|
|
<if test="updateSite != null">update_site = #{updateSite},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteEmisTransPlanRuleByIds" parameterType="String">
|
|
update emis_trans_plan_rule set del_flag = '1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectSupplierInfoByCodes" resultType="java.util.Map">
|
|
SELECT code, name
|
|
FROM emis_supplier
|
|
WHERE del_flag = '0'
|
|
AND code IN
|
|
<foreach collection="list" item="code" open="(" separator="," close=")">
|
|
#{code}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectProductTypeInfoByCodes" resultType="java.util.Map">
|
|
SELECT prod_code as code, prod_name as name
|
|
FROM emis_trans_product
|
|
WHERE del_flag = '0'
|
|
AND prod_code IN
|
|
<foreach collection="list" item="code" open="(" separator="," close=")">
|
|
#{code}
|
|
</foreach>
|
|
</select>
|
|
|
|
<!-- 根据线路编码查询运输计划规则 -->
|
|
<select id="selectTransPlanRuleByLineCode" resultMap="EmisTransPlanRuleResult">
|
|
select *
|
|
from emis_trans_plan_rule
|
|
where line_code = #{lineCode}
|
|
and del_flag = '0'
|
|
order by order_num asc
|
|
</select>
|
|
|
|
<select id="selectLineInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
|
|
SELECT line_code as code, line_name as name
|
|
FROM emis_trans_line
|
|
WHERE line_name IN
|
|
<foreach collection="list" item="name" open="(" separator="," close=")">
|
|
#{name}
|
|
</foreach>
|
|
AND del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectProductTypeInfoByNamesAndLineCode" parameterType="java.util.List" resultType="java.util.Map">
|
|
SELECT prod_code as code, prod_name as name
|
|
FROM emis_trans_product
|
|
WHERE prod_name IN
|
|
<foreach collection="productTypeNames" item="name" open="(" separator="," close=")">
|
|
#{name}
|
|
</foreach>
|
|
and trans_line_code =#{lineCode}
|
|
AND del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectSiteInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
|
|
SELECT site_code as code, site_name as name
|
|
FROM emis_site
|
|
WHERE site_name IN
|
|
<foreach collection="list" item="name" open="(" separator="," close=")">
|
|
#{name}
|
|
</foreach>
|
|
AND del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectSupplierInfoByNames" parameterType="java.util.List" resultType="java.util.Map">
|
|
SELECT code, name
|
|
FROM emis_supplier
|
|
WHERE name IN
|
|
<foreach collection="list" item="name" open="(" separator="," close=")">
|
|
#{name}
|
|
</foreach>
|
|
AND del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectRulesForAllScanPaged" resultMap="EmisTransPlanRuleResult">
|
|
select r.id, r.line_code, r.product_type, r.start_site_code, r.next_site_code, s1.site_name as start_site_name,
|
|
s2.site_name as next_site_name,
|
|
r.manager, r.supplier_code, r.start_date, r.end_date, (SELECT GROUP_CONCAT(s.name)
|
|
FROM emis_supplier s
|
|
WHERE FIND_IN_SET(s.code, r.supplier_code)
|
|
AND s.del_flag = '0') as supplier_name
|
|
from emis_trans_plan_rule r
|
|
left join emis_site s1 on r.start_site_code = s1.site_code and s1.del_flag='0'
|
|
left join emis_site s2 on r.next_site_code = s2.site_code and s2.del_flag='0'
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="emisTransPlanRule.lineCode != null and emisTransPlanRule.lineCode != ''">and r.line_code = #{emisTransPlanRule.lineCode}</if>
|
|
<if test="emisTransPlanRule.productType != null and emisTransPlanRule.productType != ''">and ( FIND_IN_SET(#{emisTransPlanRule.productType},r.product_type) )</if>
|
|
<if test="emisTransPlanRule.startSiteCode != null and emisTransPlanRule.startSiteCode != ''">and r.start_site_code = #{emisTransPlanRule.startSiteCode}</if>
|
|
<if test="emisTransPlanRule.nextSiteCode != null and emisTransPlanRule.nextSiteCode != ''">and r.next_site_code = #{emisTransPlanRule.nextSiteCode}</if>
|
|
<if test="emisTransPlanRule.manager != null and emisTransPlanRule.manager != ''">and r.manager = #{emisTransPlanRule.manager}</if>
|
|
<if test="emisTransPlanRule.supplierCode != null and emisTransPlanRule.supplierCode != ''">and ( FIND_IN_SET(#{emisTransPlanRule.supplierCode},r.supplier_code) )</if>
|
|
<if test="emisTransPlanRule.startDate != null">and r.start_date = #{emisTransPlanRule.startDate}</if>
|
|
<if test="emisTransPlanRule.endDate != null">and r.end_date = #{emisTransPlanRule.endDate}</if>
|
|
</where>
|
|
order by id desc
|
|
limit #{limit} offset #{offset}
|
|
</select>
|
|
|
|
<select id="countForAllScan" resultType="int">
|
|
select count(1)
|
|
from emis_trans_plan_rule r
|
|
<where>
|
|
r.del_flag = '0'
|
|
<if test="lineCode != null and lineCode != ''">and r.line_code = #{lineCode}</if>
|
|
<if test="productType != null and productType != ''">and ( FIND_IN_SET(#{productType},r.product_type) )</if>
|
|
<if test="startSiteCode != null and startSiteCode != ''">and r.start_site_code = #{startSiteCode}</if>
|
|
<if test="nextSiteCode != null and nextSiteCode != ''">and r.next_site_code = #{nextSiteCode}</if>
|
|
<if test="manager != null and manager != ''">and r.manager = #{manager}</if>
|
|
<if test="supplierCode != null and supplierCode != ''">and ( FIND_IN_SET(#{supplierCode},r.supplier_code) )</if>
|
|
<if test="startDate != null">and r.start_date = #{startDate}</if>
|
|
<if test="endDate != null">and r.end_date = #{endDate}</if>
|
|
</where>
|
|
</select>
|
|
|
|
</mapper> |