123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?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.ruoyi.app.mapper.SlaughterBatchMapper">
-
- <resultMap type="SlaughterBatch" id="SlaughterBatchResult">
- <result property="id" column="id" />
- <result property="slaughterTime" column="slaughter_time" />
- <result property="distributeBatchId" column="distribute_batch_id" />
- <result property="entranceBatchId" column="entrance_batch_id" />
- <result property="salePlace" column="sale_place" />
- <result property="meatCert" column="meat_cert" />
- <result property="animalCert" column="animal_cert" />
- <result property="createTime" column="create_time" />
- <result property="createBy" column="create_by" />
- <result property="updateTime" column="update_time" />
- <result property="updateBy" column="update_by" />
- <result property="delFlag" column="del_flag" />
- </resultMap>
- <resultMap id="slaughterBatchDTOResultMap" type="com.ruoyi.app.DTO.SlaughterBatchDTO">
- <!-- 主表 -->
- <id property="id" column="id"/>
- <result property="slaughterTime" column="slaughter_time"/>
- <result property="salePlace" column="sale_place"/>
- <result property="meatCert" column="meat_cert"/>
- <result property="animalCert" column="animal_cert"/>
- <!-- 分销批次 -->
- <result property="slaughterCode" column="slaughter_code"/>
- <result property="amount" column="amount"/>
- <result property="beforeWeight" column="before_weight"/>
- <!--肉商 -->
- <result property="purchaserName" column="purchaser_name"/>
- <!-- 供应商 -->
- <result property="supplierName" column="supplier_name"/>
- <!-- 入场批次 -->
- <result property="variety" column="variety"/>
- <result property="animalCertNo" column="animal_cert_no"/>
- <!-- 重量统计 -->
- <result property="sideWeight" column="side_weight"/>
- <result property="headWeight" column="head_weight"/>
- <result property="redWeight" column="red_weight"/>
- <result property="whiteWeight" column="white_weight"/>
- </resultMap>
- <resultMap id="SlaughterReportResultMap" type="com.ruoyi.app.DTO.SlaughterReportDTO">
- <!-- 主表 -->
- <id property="id" column="id"/>
- <result property="slaughterTime" column="slaughter_time"/>
- <result property="salePlace" column="sale_place"/>
- <result property="meatCert" column="meat_cert"/>
- <result property="animalCert" column="animal_cert"/>
- <!-- 分销批次 -->
- <result property="slaughterCode" column="slaughter_code"/>
- <result property="amount" column="amount"/>
- <result property="beforeWeight" column="before_weight"/>
- <!--肉商 -->
- <result property="purchaserName" column="purchaser_name"/>
- <!-- 供应商 -->
- <result property="supplierName" column="supplier_name"/>
- <!-- 入场批次 -->
- <result property="variety" column="variety"/>
- <result property="animalCertNo" column="animal_cert_no"/>
- <!-- 重量统计 -->
- <result property="sideWeight" column="side_weight"/>
- <result property="headWeight" column="head_weight"/>
- <result property="redWeight" column="red_weight"/>
- <result property="whiteWeight" column="white_weight"/>
- </resultMap>
- <resultMap type="com.ruoyi.app.DTO.PorkProduceDTO" id="PorkProduceResult">
- <result property="productName" column="product_name" />
- <result property="produceTime" column="produce_time" />
- <result property="hookNo" column="hook_no" />
- <result property="slaughterCode" column="slaughter_code" />
- <result property="finalWeight" column="final_weight" />
- </resultMap>
- <sql id="selectSlaughterBatchVo">
- select id, slaughter_time, distribute_batch_id, entrance_batch_id, sale_place, meat_cert, animal_cert, create_time, create_by, update_time, update_by, del_flag from slaughter_batch
- </sql>
- <select id="selectSlaughterBatchList" parameterType="com.ruoyi.app.domain.request.ReqSlaughterBatch" resultMap="slaughterBatchDTOResultMap">
- select a.id,a.slaughter_time,a.sale_place,a.meat_cert,a.animal_cert,
- b.slaughter_code,b.amount,b.weight as before_weight,
- c.purchaser_name,
- d.supplier_name,
- e.variety,e.animal_cert_no,
- (select sum(final_weight) from pork_side_produce where distribute_batch_id = a.distribute_batch_id and del_flag = '0') as side_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='猪头' and del_flag = '0') as head_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='红脏' and del_flag = '0') as red_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='白脏' and del_flag = '0') as white_weight
- from slaughter_batch as a
- left join distribute_batch as b on b.id = a.distribute_batch_id and b.del_flag = '0'
- left join purchaser as c on c.id = b.purchaser_id and c.del_flag = '0'
- left join supplier as d on d.id = b.supplier_id and d.del_flag = '0'
- left join entrance_batch as e on e.id = a.entrance_batch_id and e.del_flag = '0'
- <where>
- a.del_flag = '0'
- <if test="slaughterTime != null "> and DATE(a.slaughter_time) = DATE(#{slaughterTime})</if>
- <if test="animalCertNo != null and animalCertNo != ''"> and e.animal_cert_no like concat('%', #{animalCertNo}, '%')</if>
- <if test="slaughterCode != null and slaughterCode != ''"> and b.slaughter_code like concat('%', #{slaughterCode}, '%')</if>
- </where>
- order by a.slaughter_time desc
- </select>
-
- <select id="selectSlaughterBatchById" parameterType="Long" resultMap="slaughterBatchDTOResultMap">
- select a.id,a.slaughter_time,a.sale_place,a.meat_cert,animal_cert,
- b.slaughter_code,b.amount,b.weight as before_weight,
- c.purchaser_name,
- d.supplier_name,
- e.variety,e.animal_cert_no,
- (select sum(final_weight) from pork_side_produce where distribute_batch_id = a.distribute_batch_id and del_flag = '0') as side_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='猪头' and del_flag = '0') as head_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='红脏' and del_flag = '0') as red_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='白脏' and del_flag = '0') as white_weight
- from slaughter_batch as a
- left join distribute_batch as b on b.id = a.distribute_batch_id and b.del_flag = '0'
- left join purchaser as c on c.id = b.purchaser_id and c.del_flag = '0'
- left join supplier as d on d.id = b.supplier_id and d.del_flag = '0'
- left join entrance_batch as e on e.id = a.entrance_batch_id and e.del_flag = '0'
- where a.id = #{id} and a.del_flag = '0'
- </select>
- <insert id="insertSlaughterBatch" parameterType="SlaughterBatch" useGeneratedKeys="true" keyProperty="id">
- insert into slaughter_batch
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="slaughterTime != null">slaughter_time,</if>
- <if test="distributeBatchId != null">distribute_batch_id,</if>
- <if test="entranceBatchId != null">entrance_batch_id,</if>
- <if test="salePlace != null">sale_place,</if>
- <if test="meatCert != null">meat_cert,</if>
- <if test="animalCert != null">animal_cert,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- del_flag
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="slaughterTime != null">#{slaughterTime},</if>
- <if test="distributeBatchId != null">#{distributeBatchId},</if>
- <if test="entranceBatchId != null">#{entranceBatchId},</if>
- <if test="salePlace != null">#{salePlace},</if>
- <if test="meatCert != null">#{meatCert},</if>
- <if test="animalCert != null">#{animalCert},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- '0'
- </trim>
- </insert>
- <update id="updateSlaughterBatch" parameterType="SlaughterBatch">
- update slaughter_batch
- <trim prefix="SET" suffixOverrides=",">
- <if test="slaughterTime != null">slaughter_time = #{slaughterTime},</if>
- <if test="distributeBatchId != null">distribute_batch_id = #{distributeBatchId},</if>
- <if test="entranceBatchId != null">entrance_batch_id = #{entranceBatchId},</if>
- <if test="salePlace != null">sale_place = #{salePlace},</if>
- <if test="meatCert != null">meat_cert = #{meatCert},</if>
- <if test="animalCert != null">animal_cert = #{animalCert},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteSlaughterBatchById" parameterType="Long">
- update slaughter_batch set del_flag = '2' where id = #{id}
- </delete>
- <!--根据分销批次删除屠宰批次-->
- <delete id="deleteSlaughterBatchByDistributeId" parameterType="Long">
- update slaughter_batch set del_flag = '2' where distribute_batch_id = #{id}
- </delete>
- <delete id="deleteSlaughterBatchByIds" parameterType="String">
- update slaughter_batch set del_flag = '2' where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!--根据分销批次批量删除屠宰批次-->
- <delete id="deleteSlaughterBatchByDistributeIds" parameterType="String">
- update slaughter_batch set del_flag = '2' where distribute_batch_id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!--根据入场批次和分销批次ID获取各部位称重记录-->
- <select id="selectPorkProduceByBatch" parameterType="com.ruoyi.app.domain.request.ReqEntranceAndDistribute" resultMap="PorkProduceResult">
- (
- select product_name,produce_time,hook_no,slaughter_code,final_weight
- from pork_side_produce
- <where>
- del_flag = '0'
- <if test="entranceBatchId != null "> and entrance_batch_id = #{entranceBatchId}</if>
- <if test="distributeBatchId != null "> and distribute_batch_id = #{distributeBatchId}</if>
- </where>
- )
- union all
- (
- select product_name,produce_time,'-' as hook_no,slaughter_code,final_weight
- from pork_other_produce
- <where>
- del_flag = '0'
- <if test="entranceBatchId != null "> and entrance_batch_id = #{entranceBatchId}</if>
- <if test="distributeBatchId != null "> and distribute_batch_id = #{distributeBatchId}</if>
- </where>
- )
- order by produce_time desc
- </select>
- <!--生产情况报表-->
- <select id="selectSlaughterReport" parameterType="com.ruoyi.app.domain.request.ReqSlaughterReport" resultMap="SlaughterReportResultMap">
- select a.id,a.slaughter_time,a.sale_place,a.meat_cert,a.animal_cert,
- b.slaughter_code,b.amount,b.weight as before_weight,
- c.purchaser_name,
- d.supplier_name,
- (select sum(final_weight) from pork_side_produce where distribute_batch_id = a.distribute_batch_id and del_flag = '0') as side_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='猪头' and del_flag = '0') as head_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='红脏' and del_flag = '0') as red_weight,
- (select sum(final_weight) from pork_other_produce where distribute_batch_id = a.distribute_batch_id and product_name='白脏' and del_flag = '0') as white_weight
- from slaughter_batch as a
- left join distribute_batch as b on b.id = a.distribute_batch_id and b.del_flag = '0'
- left join purchaser as c on c.id = b.purchaser_id and c.del_flag = '0'
- left join supplier as d on d.id = b.supplier_id and d.del_flag = '0'
- left join entrance_batch as e on e.id = a.entrance_batch_id and e.del_flag = '0'
- <where>
- a.del_flag = '0'
- <if test="slaughterTime != null "> and DATE(a.slaughter_time) = DATE(#{slaughterTime})</if>
- <if test="purchaserName != null and purchaserName != ''"> and c.purchaser_name like concat('%', #{purchaserName}, '%')</if>
- <if test="supplierName != null and supplierName != ''"> and d.supplier_name like concat('%', #{supplierName}, '%')</if>
- </where>
- order by a.slaughter_time desc
- </select>
- <select id="getAllList" resultType="com.ruoyi.app.DTO.ProductionVo">
- select b.productName produceName,a.afterWeight weight,b.unit unit,a.amount amount FROM
- (select produce_name produceName,SUM(after_weight) afterWeight,SUM(amount) amount FROM js_distribution where purchaser_name=#{purchaserName}
- <if test="animalCertNo != null "> and animal_cert_no = #{animalCertNo}</if>
- GROUP BY produce_name)
- as a right JOIN
- (select product_name productName,unit unit FROM product_category WHERE del_flag='0') AS b
- on a.produceName=b.productName
- </select>
- </mapper>
|