123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 |
- <?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.EntranceBatchMapper">
-
- <resultMap type="EntranceBatch" id="EntranceBatchResult">
- <result property="id" column="id" />
- <result property="supplierId" column="supplier_id" />
- <result property="originPlace" column="origin_place" />
- <result property="entranceTime" column="entrance_time" />
- <result property="variety" column="variety" />
- <result property="transportVehicle" column="transport_vehicle" />
- <result property="weight" column="weight" />
- <result property="pigpens" column="pigpens" />
- <result property="animalCertNo" column="animal_cert_no" />
- <result property="animalCertPics" column="animal_cert_pics" />
- <result property="cargoOwner" column="cargo_owner" />
- <result property="companyNo" column="company_no" />
- <result property="cargoOwnerPhone" column="cargo_owner_phone" />
- <result property="animalCategory" column="animal_category" />
- <result property="amount" column="amount" />
- <result property="units" column="units" />
- <result property="useto" column="useto" />
- <result property="fromPlace" column="from_place" />
- <result property="toPlace" column="to_place" />
- <result property="carrier" column="carrier" />
- <result property="carrierPhone" column="carrier_phone" />
- <result property="animalEartags" column="animal_eartags" />
- <result property="remark" column="remark" />
- <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" />
- <association property="harmlessTreatment" javaType="HarmlessTreatment" resultMap="HarmlessTreatmentResult" />
- <association property="supplier" javaType="Supplier" resultMap="SupplierResult" />
- </resultMap>
- <resultMap type="Supplier" id="SupplierResult">
- <result property="id" column="id" />
- <result property="supplierName" column="supplier_name" />
- <result property="phone" column="phone" />
- <result property="supplySpecies" column="supply_species" />
- <result property="businessPlace" column="business_place" />
- <result property="originPlace" column="origin_place" />
- <result property="region" column="region" />
- <result property="evaluate" column="evaluate" />
- <result property="remark" column="remark" />
- <result property="inBlacklist" column="in_blacklist" />
- <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 type="HarmlessTreatment" id="HarmlessTreatmentResult">
- <result property="id" column="id" />
- <result property="entranceBatchId" column="entrance_batch_id" />
- <result property="illnessDeadAmount" column="illness_dead_amount" />
- <result property="illnessDiseaseAmount" column="illness_disease_amount" />
- <result property="snapKillAmount" column="snap_kill_amount" />
- <result property="unqualifiedWeight" column="unqualified_weight" />
- <result property="illnessPigsDetail" column="illness_pigs_detail" />
- <result property="dealReason" column="deal_reason" />
- <result property="dealWay" column="deal_way" />
- <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 type="com.ruoyi.app.DTO.TimeAndNumberDTO" id="TimeAndNumberDTOResult">
- <result property="timeSpot" column="time_spot" />
- <result property="totalAmount" column="total_amount" />
- </resultMap>
- <resultMap id="productTraceResultMap" type="com.ruoyi.app.DTO.ProductTraceDTO">
- <result property="entranceBatchId" column="entrance_batch_id"/>
- <result property="animalCertNo" column="animal_cert_no"/>
- <result property="entranceTime" column="entrance_time"/>
- <result property="cargoOwner" column="cargo_owner"/>
- <result property="companyNo" column="company_no"/>
- <result property="animalCategory" column="animal_category"/>
- <result property="variety" column="variety"/>
- <result property="amount" column="amount"/>
- <result property="units" column="units"/>
- <result property="fromPlace" column="from_place"/>
- <result property="toPlace" column="to_place"/>
- <result property="carrier" column="carrier"/>
- <result property="cargoOwnerPhone" column="cargo_owner_phone"/>
- <result property="carrierPhone" column="carrier_phone"/>
- <result property="spirit" column="spirit"/>
- <result property="appearance" column="appearance"/>
- <result property="breathe" column="breathe"/>
- <result property="metabolite" column="metabolite"/>
- <result property="otherRemark" column="other_remark"/>
- <result property="inspectionDetail" column="inspection_detail"/>
- <result property="illnessDeadAmount" column="illness_dead_amount"/>
- <result property="illnessDiseaseAmount" column="illness_disease_amount"/>
- <result property="snapKillAmount" column="snap_kill_amount"/>
- <result property="unqualifiedWeight" column="unqualified_weight"/>
- <result property="dealWay" column="deal_way"/>
- <result property="totalSideWeight" column="total_side_weight"/>
- <result property="totalHeadWeight" column="total_head_weight"/>
- <result property="totalRedWeight" column="total_red_weight"/>
- <result property="totalWhiteWeight" column="total_white_weight"/>
- <!-- 处理 slaughterBatchDTO 集合 -->
- <collection property="slaughterBatchs" ofType="com.ruoyi.app.DTO.SlaughterBatchDTO">
- <!-- 主表 -->
- <id property="id" column="distribute_batch_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="slaughter_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"/>
- </collection>
- </resultMap>
- <resultMap id="entranceReportResultMap" type="com.ruoyi.app.DTO.EntranceReportDTO">
- <result property="entranceTime" column="entrance_time"/>
- <result property="animalCertNo" column="animal_cert_no"/>
- <result property="animalEartags" column="animal_eartags"/>
- <result property="amount" column="amount"/>
- <result property="weight" column="weight"/>
- <result property="pigpens" column="pigpens"/>
- <result property="supplierName" column="supplier_name"/>
- <result property="originPlace" column="origin_place"/>
- <result property="illnessDeadAmount" column="illness_dead_amount"/>
- <result property="illnessDiseaseAmount" column="illness_disease_amount"/>
- <result property="snapKillAmount" column="snap_kill_amount"/>
- <result property="unqualifiedWeight" column="unqualified_weight"/>
- <result property="illnessPigsDetail" column="illness_pigs_detail"/>
- <result property="dealWay" column="deal_way"/>
- <result property="inspectionDetail" column="inspection_detail"/>
- </resultMap>
- <resultMap type="com.ruoyi.app.DTO.DailyEntranceAmountDTO" id="DailyEntranceAmountResult">
- <result property="illnessDeadAmountSum" column="illness_dead_amount_sum" />
- <result property="illnessDiseaseAmountSum" column="illness_disease_amount_sum" />
- <result property="entranceAmountSum" column="entrance_amount_sum" />
- </resultMap>
- <sql id="selectEntranceBatchVo">
- select id, supplier_id,origin_place,entrance_time, variety, transport_vehicle, weight, pigpens, animal_cert_no,animal_cert_pics, cargo_owner, company_no, cargo_owner_phone, animal_category, amount, units, useto, from_place, to_place, carrier, carrier_phone, animal_eartags, remark, create_time,create_by, update_time, update_by, del_flag from entrance_batch
- </sql>
- <select id="selectEntranceBatchList" parameterType="EntranceBatch" resultMap="EntranceBatchResult">
- select a.id, a.entrance_time,a.animal_cert_no, a.cargo_owner,a.amount,a.supplier_id,a.variety,
- b.supplier_name,
- c.illness_dead_amount,c.illness_disease_amount,c.snap_kill_amount,c.unqualified_weight
- from entrance_batch as a
- left join supplier as b on b.id = a.supplier_id and b.del_flag = '0'
- left join harmless_treatment as c on c.entrance_batch_id = a.id and c.del_flag = '0'
- <where>
- a.del_flag = '0'
- <if test="supplierId != null "> and a.supplier_id = #{supplierId}</if>
- <if test="entranceTime != null "> and a.entrance_time >= #{entranceTime}</if>
- <if test="animalCertNo != null and animalCertNo != ''"> and a.animal_cert_no like concat('%', #{animalCertNo}, '%')</if>
- </where>
- order by a.entrance_time desc,a.id desc
- </select>
- <select id="selectEntranceBatchDetailById" parameterType="Long" resultMap="EntranceBatchResult">
- select a.*,b.phone,b.origin_place,b.region,b.business_place
- from entrance_batch as a
- left join supplier as b on b.id = a.supplier_id and b.del_flag = '0'
- where a.id = #{id} and a.del_flag = '0'
- </select>
- <select id="selectEntranceBatchById" parameterType="Long" resultMap="EntranceBatchResult">
- select a.id, a.entrance_time,a.animal_cert_no, a.cargo_owner,a.amount,a.supplier_id,a.variety,
- c.illness_dead_amount,c.illness_disease_amount,c.snap_kill_amount,c.unqualified_weight
- from entrance_batch as a
- left join harmless_treatment as c on c.entrance_batch_id = a.id and c.del_flag = '0'
- where a.id = #{id} and a.del_flag = '0'
- </select>
- <!--检查检疫证号是否存在-->
- <select id="checkAnimalCertNoUnique" parameterType="String" resultMap="EntranceBatchResult">
- select id, animal_cert_no from entrance_batch where animal_cert_no = #{animalCertNo} and del_flag = '0' limit 1
- </select>
- <insert id="insertEntranceBatch" parameterType="EntranceBatch" useGeneratedKeys="true" keyProperty="id">
- insert into entrance_batch
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="supplierId != null">supplier_id,</if>
- <if test="originPlace != null">origin_place,</if>
- <if test="entranceTime != null">entrance_time,</if>
- <if test="variety != null">variety,</if>
- <if test="transportVehicle != null">transport_vehicle,</if>
- <if test="weight != null">weight,</if>
- <if test="pigpens != null">pigpens,</if>
- <if test="animalCertNo != null">animal_cert_no,</if>
- <if test="animalCertPics != null">animal_cert_pics,</if>
- <if test="cargoOwner != null">cargo_owner,</if>
- <if test="companyNo != null">company_no,</if>
- <if test="cargoOwnerPhone != null">cargo_owner_phone,</if>
- <if test="animalCategory != null">animal_category,</if>
- <if test="amount != null">amount,</if>
- <if test="units != null">units,</if>
- <if test="useto != null">useto,</if>
- <if test="fromPlace != null">from_place,</if>
- <if test="toPlace != null">to_place,</if>
- <if test="carrier != null">carrier,</if>
- <if test="carrierPhone != null">carrier_phone,</if>
- <if test="animalEartags != null">animal_eartags,</if>
- <if test="remark != null">remark,</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="supplierId != null">#{supplierId},</if>
- <if test="originPlace != null">#{originPlace},</if>
- <if test="entranceTime != null">#{entranceTime},</if>
- <if test="variety != null">#{variety},</if>
- <if test="transportVehicle != null">#{transportVehicle},</if>
- <if test="weight != null">#{weight},</if>
- <if test="pigpens != null">#{pigpens},</if>
- <if test="animalCertNo != null">#{animalCertNo},</if>
- <if test="animalCertPics != null">#{animalCertPics},</if>
- <if test="cargoOwner != null">#{cargoOwner},</if>
- <if test="companyNo != null">#{companyNo},</if>
- <if test="cargoOwnerPhone != null">#{cargoOwnerPhone},</if>
- <if test="animalCategory != null">#{animalCategory},</if>
- <if test="amount != null">#{amount},</if>
- <if test="units != null">#{units},</if>
- <if test="useto != null">#{useto},</if>
- <if test="fromPlace != null">#{fromPlace},</if>
- <if test="toPlace != null">#{toPlace},</if>
- <if test="carrier != null">#{carrier},</if>
- <if test="carrierPhone != null">#{carrierPhone},</if>
- <if test="animalEartags != null">#{animalEartags},</if>
- <if test="remark != null">#{remark},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- '0'
- </trim>
- </insert>
- <update id="updateEntranceBatch" parameterType="EntranceBatch">
- update entrance_batch
- <trim prefix="SET" suffixOverrides=",">
- <if test="supplierId != null">supplier_id = #{supplierId},</if>
- <if test="originPlace != null">origin_place = #{originPlace},</if>
- <if test="entranceTime != null">entrance_time = #{entranceTime},</if>
- <if test="variety != null">variety = #{variety},</if>
- <if test="transportVehicle != null">transport_vehicle = #{transportVehicle},</if>
- <if test="weight != null">weight = #{weight},</if>
- <if test="pigpens != null">pigpens = #{pigpens},</if>
- <if test="animalCertNo != null">animal_cert_no = #{animalCertNo},</if>
- <if test="animalCertPics != null">animal_cert_pics = #{animalCertPics},</if>
- <if test="cargoOwner != null">cargo_owner = #{cargoOwner},</if>
- <if test="companyNo != null">company_no = #{companyNo},</if>
- <if test="cargoOwnerPhone != null">cargo_owner_phone = #{cargoOwnerPhone},</if>
- <if test="animalCategory != null">animal_category = #{animalCategory},</if>
- <if test="amount != null">amount = #{amount},</if>
- <if test="units != null">units = #{units},</if>
- <if test="useto != null">useto = #{useto},</if>
- <if test="fromPlace != null">from_place = #{fromPlace},</if>
- <if test="toPlace != null">to_place = #{toPlace},</if>
- <if test="carrier != null">carrier = #{carrier},</if>
- <if test="carrierPhone != null">carrier_phone = #{carrierPhone},</if>
- <if test="animalEartags != null">animal_eartags = #{animalEartags},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteEntranceBatchById" parameterType="Long">
- update entrance_batch set del_flag = '2' where id = #{id}
- </delete>
- <delete id="deleteEntranceBatchByIds" parameterType="String">
- update entrance_batch set del_flag = '2' where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!--获取最近的一条记录-->
- <select id="selectLatelyEntrance" resultMap="EntranceBatchResult">
- select * from entrance_batch
- <where>
- del_flag = '0'
- </where>
- order by entrance_time desc
- limit 1
- </select>
- <!--根据时间范围获取入场次数-->
- <select id="selectCountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultType="Long">
- select count(1) from entrance_batch
- <where>
- del_flag = '0'
- <if test="startTime != null "> and entrance_time <![CDATA[ >= ]]> #{startTime}</if>
- <if test="endTime != null "> and entrance_time <![CDATA[ <= ]]> #{endTime}</if>
- </where>
- </select>
- <!--根据时间范围获取今日入场次数-->
- <select id="selectTodayCount" resultType="Long">
- select count(1) from entrance_batch
- <where>
- del_flag = '0'
- and entrance_time <![CDATA[ >= ]]> CURDATE()
- and entrance_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)
- </where>
- </select>
- <!--根据时间范围获取昨日入场次数-->
- <select id="selectYesterdayCount" resultType="Long">
- select count(1) from entrance_batch
- <where>
- del_flag = '0'
- and entrance_time <![CDATA[ >= ]]> DATE_SUB(CURDATE(), INTERVAL 1 DAY)
- and entrance_time <![CDATA[ < ]]> CURDATE()
- </where>
- </select>
- <!--根据时间范围获取累计计划屠宰-->
- <select id="selectAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultType="Long">
- select IFNULL(sum(amount),0) from entrance_batch
- <where>
- del_flag = '0'
- <if test="startTime != null "> and entrance_time <![CDATA[ >= ]]> #{startTime}</if>
- <if test="endTime != null "> and entrance_time <![CDATA[ <= ]]> #{endTime}</if>
- </where>
- </select>
- <!--根据时间范围获取今日累计计划屠宰-->
- <select id="selectTodayAmount" resultMap="DailyEntranceAmountResult">
- select IFNULL(sum(b.amount),0) as entrance_amount_sum,IFNULL(sum(illness_dead_amount),0) as illness_dead_amount_sum,IFNULL(sum(illness_disease_amount),0) as illness_disease_amount_sum
- from harmless_treatment as a
- left join entrance_batch as b on b.id = a.entrance_batch_id
- <where>
- a.del_flag = '0' and b.del_flag = '0'
- and b.entrance_time <![CDATA[ >= ]]> CURDATE()
- and b.entrance_time <![CDATA[ < ]]> DATE_ADD(CURDATE(), INTERVAL 1 DAY)
- </where>
- </select>
- <!--根据时间范围获取昨日累计计划屠宰-->
- <select id="selectYesterdayAmount" resultMap="DailyEntranceAmountResult">
- select IFNULL(sum(b.amount),0) as entrance_amount_sum,IFNULL(sum(illness_dead_amount),0) as illness_dead_amount_sum,IFNULL(sum(illness_disease_amount),0) as illness_disease_amount_sum
- from harmless_treatment as a
- left join entrance_batch as b on b.id = a.entrance_batch_id
- <where>
- a.del_flag = '0' and b.del_flag = '0'
- and b.entrance_time <![CDATA[ >= ]]> DATE_SUB(CURDATE(), INTERVAL 1 DAY)
- and b.entrance_time <![CDATA[ < ]]> CURDATE()
- </where>
- </select>
- <!--统计按年全部数据-->
- <select id="selectAllYearAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- YEAR(entrance_time) AS time_spot,
- IFNULL(SUM(amount),0) AS total_amount
- FROM
- entrance_batch
- where del_flag = '0'
- GROUP BY
- YEAR(entrance_time)
- ORDER BY
- time_spot;
- </select>
- <!--根据获取近一年每月累计计划屠宰-->
- <select id="selectYearAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- months.month_period as time_spot,
- IFNULL(SUM(eb.amount), 0) AS total_amount
- FROM (
- SELECT
- DATE_FORMAT(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL seq MONTH), '%Y-%m') AS month_period,
- DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL seq MONTH) AS month_start,
- LAST_DAY(DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL seq MONTH)) AS month_end
- FROM (
- SELECT 0 AS seq UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL
- SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL
- SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL
- SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11
- ) AS sequences
- ) AS months
- LEFT JOIN entrance_batch eb ON
- eb.entrance_time BETWEEN months.month_start AND months.month_end and eb.del_flag = '0'
- GROUP BY
- months.month_period, months.month_start, months.month_end
- ORDER BY
- months.month_start;
- </select>
- <!--根据获取近三十天的每日累计计划屠宰-->
- <select id="selectMonthAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- dates.date AS time_spot,
- IFNULL(SUM(eb.amount), 0) AS total_amount
- FROM (
- SELECT DATE_SUB(CURDATE(), INTERVAL seq DAY) AS date
- FROM (
- SELECT 0 AS seq UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL
- SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL
- SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL
- SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
- SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL
- SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL
- SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL
- SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL
- SELECT 24 UNION ALL SELECT 25 UNION ALL SELECT 26 UNION ALL
- SELECT 27 UNION ALL SELECT 28 UNION ALL SELECT 29
- ) AS sequences
- ) AS dates
- LEFT JOIN entrance_batch eb ON
- DATE(eb.entrance_time) = dates.date and eb.del_flag = '0'
- GROUP BY
- dates.date
- ORDER BY
- dates.date;
- </select>
- <!--根据获取近七天的每日累计计划屠宰-->
- <select id="selectWeekAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- dates.date AS time_spot,
- IFNULL(SUM(eb.amount), 0) AS total_amount
- FROM (
- SELECT CURDATE() AS date UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 3 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 4 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 5 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 6 DAY)
- ) AS dates
- LEFT JOIN entrance_batch eb ON
- DATE(eb.entrance_time) = dates.date and eb.del_flag = '0'
- GROUP BY
- dates.date
- ORDER BY
- dates.date;
- </select>
- <!--根据获取每小时累计计划屠宰-->
- <select id="selectTodayAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- hours.hour AS time_spot,
- IFNULL(SUM(eb.amount), 0) AS total_amount
- FROM (
- SELECT '00:00' AS hour UNION SELECT '01:00' UNION SELECT '02:00' UNION SELECT '03:00'
- UNION SELECT '04:00' UNION SELECT '05:00' UNION SELECT '06:00' UNION SELECT '07:00'
- UNION SELECT '08:00' UNION SELECT '09:00' UNION SELECT '10:00' UNION SELECT '11:00'
- UNION SELECT '12:00' UNION SELECT '13:00' UNION SELECT '14:00' UNION SELECT '15:00'
- UNION SELECT '16:00' UNION SELECT '17:00' UNION SELECT '18:00' UNION SELECT '19:00'
- UNION SELECT '20:00' UNION SELECT '21:00' UNION SELECT '22:00' UNION SELECT '23:00'
- ) AS hours
- LEFT JOIN entrance_batch eb ON
- DATE_FORMAT(eb.entrance_time, '%H:00') = hours.hour
- AND DATE(eb.entrance_time) = CURDATE() and eb.del_flag = '0'
- GROUP BY
- hours.hour
- ORDER BY
- hours.hour;
- </select>
- <!--根据获取指定时间范围内每日累计计划屠宰-->
- <select id="selectRangeAmountByTime" parameterType="com.ruoyi.app.domain.request.TimeRangeParam" resultMap="TimeAndNumberDTOResult">
- SELECT
- DATE_FORMAT(dates.date, '%Y-%m-%d') AS time_spot,
- IFNULL(SUM(eb.amount), 0) AS total_amount
- FROM (
- SELECT DATE_ADD(#{startTime}, INTERVAL seq DAY) AS date
- FROM (
- SELECT a.n + b.n*10 + c.n*100 AS seq
- FROM
- (SELECT 0 AS n UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
- UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) a,
- (SELECT 0 AS n UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
- UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) b,
- (SELECT 0 AS n UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
- UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) c
- WHERE a.n + b.n*10 + c.n*100 <![CDATA[ <= ]]> DATEDIFF(#{endTime}, #{startTime})
- ) AS sequences
- ) AS dates
- LEFT JOIN entrance_batch eb ON
- DATE(eb.entrance_time) = dates.date
- AND eb.del_flag = '0'
- GROUP BY
- dates.date
- ORDER BY
- dates.date
- </select>
- <!--根据获取近七天的每日入场订单-->
- <select id="selectWeekCountByTime" resultMap="TimeAndNumberDTOResult">
- SELECT
- dates.date AS time_spot,
- IFNULL(count(eb.id), 0) AS total_amount
- FROM (
- SELECT CURDATE() AS date UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 3 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 4 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 5 DAY) UNION ALL
- SELECT DATE_SUB(CURDATE(), INTERVAL 6 DAY)
- ) AS dates
- LEFT JOIN entrance_batch eb ON
- DATE(eb.entrance_time) = dates.date and eb.del_flag = '0'
- GROUP BY
- dates.date
- ORDER BY
- dates.date;
- </select>
- <!--产品追溯-根据肉商名称,供应商名称,血码,检疫证号查询-->
- <select id="selectProductTrace" parameterType="com.ruoyi.app.domain.request.ProductTraceParam" resultMap="productTraceResultMap">
- select
- a.id as entrance_batch_id,
- a.animal_cert_no,a.entrance_time,a.cargo_owner,a.company_no,a.animal_category,a.variety,a.amount,a.units,a.from_place,a.to_place,a.carrier,a.cargo_owner_phone,a.carrier_phone,
- f.spirit,f.appearance,f.breathe,f.metabolite,f.other_remark,f.inspection_detail,
- IFNULL(g.illness_dead_amount,0) as illness_dead_amount,IFNULL(g.illness_disease_amount,0) as illness_disease_amount,
- IFNULL(g.snap_kill_amount,0) as snap_kill_amount,IFNULL(g.unqualified_weight,0) as unqualified_weight,g.deal_way,
- slaughter_distribute.id as distribute_batch_id,
- slaughter_distribute.slaughter_code,slaughter_distribute.amount as slaughter_amount,slaughter_distribute.before_weight,
- slaughter_distribute.side_weight,slaughter_distribute.head_weight,slaughter_distribute.red_weight,slaughter_distribute.white_weight,
- slaughter_distribute.supplier_name,slaughter_distribute.purchaser_name,slaughter_distribute.sale_place,
- slaughter_distribute.meat_cert,slaughter_distribute.animal_cert
- from entrance_batch as a
- left join (
- select
- distribute.entrance_batch_id,
- distribute.id,
- distribute.slaughter_code,distribute.amount,distribute.weight as before_weight,
- supplier.supplier_name,
- purchaser.purchaser_name,
- slaughter.sale_place,slaughter.meat_cert,slaughter.animal_cert,
- (select IFNULL(sum(final_weight),0) from pork_side_produce where distribute_batch_id = distribute.id and del_flag = '0') as side_weight,
- (select IFNULL(sum(final_weight),0) from pork_other_produce where distribute_batch_id = distribute.id and product_name='猪头' and del_flag = '0') as head_weight,
- (select IFNULL(sum(final_weight),0) from pork_other_produce where distribute_batch_id = distribute.id and product_name='红脏' and del_flag = '0') as red_weight,
- (select IFNULL(sum(final_weight),0) from pork_other_produce where distribute_batch_id = distribute.id and product_name='白脏' and del_flag = '0') as white_weight
- from distribute_batch as distribute
- left join supplier on supplier.id = distribute.supplier_id and supplier.del_flag = '0'
- left join purchaser on purchaser.id = distribute.purchaser_id and purchaser.del_flag = '0'
- left join slaughter_batch as slaughter on slaughter.distribute_batch_id = distribute.id and slaughter.del_flag = '0'
- where distribute.del_flag = '0'
- ) as slaughter_distribute on slaughter_distribute.entrance_batch_id = a.id
- left join entrance_inspection as f on f.entrance_batch_id = a.id and f.del_flag = '0'
- left join harmless_treatment as g on g.entrance_batch_id = a.id and g.del_flag = '0'
- <where>
- a.del_flag = '0'
- <if test="animalCertNo != null "> and a.animal_cert_no = #{animalCertNo}</if>
- <if test="slaughterCode != null "> and slaughter_distribute.slaughter_code = #{slaughterCode}</if>
- <if test="supplierName != null "> and slaughter_distribute.supplier_name = #{supplierName}</if>
- <if test="purchaserName != null "> and slaughter_distribute.purchaser_name = #{purchaserName}</if>
- </where>
- order by a.entrance_time desc
- </select>
- <!--入场统计报表-->
- <select id="selectEntranceReport" parameterType="com.ruoyi.app.domain.request.ReqEntranceReport" resultMap="entranceReportResultMap">
- select
- a.entrance_time,a.origin_place,a.animal_cert_no,a.animal_eartags,a.amount,a.weight,
- b.supplier_name,
- c.illness_dead_amount,c.illness_disease_amount,c.snap_kill_amount,c.unqualified_weight,c.deal_way,c.illness_pigs_detail,
- d.inspection_detail
- from entrance_batch as a
- left join supplier as b on b.id = a.supplier_id and b.del_flag = '0'
- left join harmless_treatment as c on c.entrance_batch_id = a.id and c.del_flag = '0'
- left join entrance_inspection as d on d.entrance_batch_id = a.id and d.del_flag = '0'
- <where>
- a.del_flag = '0'
- <if test="animalCertNo != null "> and a.animal_cert_no like concat('%', #{animalCertNo}, '%')</if>
- <if test="supplierName != null "> and b.supplier_name like concat('%', #{supplierName}, '%')</if>
- <if test="entranceTime != null "> and DATE(a.entrance_time) = DATE(#{entranceTime})</if>
- </where>
- order by a.entrance_time desc
- </select>
- <!--根据供应商ID统计入场批次数量-->
- <select id="countBatchBySupplier" parameterType="Long" resultType="Integer">
- select count(1) from entrance_batch
- where supplier_id = #{supplierId} and del_flag = '0'
- </select>
- <select id="selectByAnimalNo" parameterType="string" resultType="com.ruoyi.app.domain.EntranceBatch">
- select * from entrance_batch where animal_cert_no=#{anNo}
- </select>
- </mapper>
|