From 9051165798048f48968f0c48cb0d111fca3d214d Mon Sep 17 00:00:00 2001 From: zyh <2066096076@qq.com> Date: Fri, 22 Aug 2025 19:32:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8C=89=E7=85=A7=E6=97=A5=E6=9C=9F=E9=99=8D?= =?UTF-8?q?=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml | 1 + .../resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml | 1 + .../resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml | 1 + .../resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml | 1 + .../mapper/produce/manage_sheep/ScChangeCommentMapper.xml | 1 + .../resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml | 1 + .../mapper/produce/manage_sheep/ScChangeVarietyMapper.xml | 1 + .../resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml | 1 + .../mapper/produce/manage_sheep/ScTransitionInfoMapper.xml | 1 + .../src/main/resources/mapper/produce/other/ScCastrateMapper.xml | 1 + .../src/main/resources/mapper/produce/other/ScFixHoofMapper.xml | 1 + 11 files changed, 11 insertions(+) diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml index 5265e5f..7e75d9c 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml @@ -102,6 +102,7 @@ and sm.create_time between #{params.beginCreateTime} and #{params.endCreateTime} + ORDER BY sm.create_time DESC diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml index 78b2c91..66d18ca 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransitionInfoMapper.xml @@ -67,6 +67,7 @@ and t.create_time between #{params.beginCreateTime} and #{params.endCreateTime} + ORDER BY t.create_time DESC diff --git a/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml index f86bdef..e767362 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml @@ -7,6 +7,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + @@ -31,7 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, name, use_type, update_by, update_time, create_by, create_time from sw_medicine_usage + select smu.id, sheepfold as sheepfold_id,sheep sheep_id,name, datetime,use_type, smu.update_by, smu.update_time, smu.create_by, smu.create_time, + ds.sheepfold_name, + bs.manage_tags sheep_no + from sw_medicine_usage smu + left join da_sheepfold ds on ds.id = smu.sheepfold + left join bas_sheep bs on bs.id = smu.sheep @@ -62,6 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" name, use_type, + sheepfold, + sheep, + datetime, update_by, update_time, create_by, @@ -70,6 +87,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{name}, #{useType}, + #{sheepfoldId}, + #{sheepId}, + #{datetime}, #{updateBy}, #{updateTime}, #{createBy}, diff --git a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml index ee496ad..031bb74 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml @@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and disease_id = #{diseaseId} and veterinary = #{veterinary} + ORDER BY datetime DESC + + + and smr.sheep_id = #{sheepId} + and sf.bs_manage_tags like concat('%', #{bsManageTags}, '%') + and smr.datetime = #{datetime} + and smr.comment like concat('%', #{comment}, '%') + and smr.technician like concat('%', #{technician}, '%') + and smr.reason = #{reason} + and smr.expose_type = #{exposeType} + and smr.status = #{status} + and smr.misca_lamb = #{miscaLamb} + and sf.variety like concat('%', #{variety}, '%') + + order by smr.create_time desc + + + + + + insert into sc_miscarriage_record + + sheep_id, + datetime, + comment, + technician, + reason, + expose_type, + status, + misca_lamb, + create_by, + create_time, + + + #{sheepId}, + #{datetime}, + #{comment}, + #{technician}, + #{reason}, + #{exposeType}, + #{status}, + #{miscaLamb}, + #{createBy}, + #{createTime}, + + + + + update sc_miscarriage_record + + sheep_id = #{sheepId}, + datetime = #{datetime}, + comment = #{comment}, + technician = #{technician}, + reason = #{reason}, + expose_type = #{exposeType}, + status = #{status}, + misca_lamb = #{miscaLamb}, + create_by = #{createBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from sc_miscarriage_record where id = #{id} + + + + delete from sc_miscarriage_record where id in + + #{id} + + + + + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/breed/ScPregnancyRecordMapper.xml b/zhyc-module/src/main/resources/mapper/produce/breed/ScPregnancyRecordMapper.xml index 3017f1a..c6a34a3 100644 --- a/zhyc-module/src/main/resources/mapper/produce/breed/ScPregnancyRecordMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/breed/ScPregnancyRecordMapper.xml @@ -16,8 +16,6 @@ - - @@ -32,6 +30,7 @@ + @@ -46,8 +45,6 @@ pr.remark, pr.create_by, pr.create_time, - pr.create_by, - pr.create_time, sf.bs_manage_tags as manage_tags, sf.variety, sf.month_age, @@ -55,18 +52,37 @@ sf.mating_counts, sf.sheepfold_name, sf.breed, - sf.father_manage_tags, - father_sf.variety as father_variety, - mating_type.dict_label as mating_type_name, - sf.mating_date, sf.expected_date, sf.lambing_date as last_event_date, - r.ranch as ranch + sf.dr_ranch as ranch, + -- 关联配种信息 + ram_sf.bs_manage_tags as father_manage_tags, + ram_sf.variety as father_variety, + mating_type.dict_label as mating_type_name, + COALESCE(br.create_time, sf.mating_date) as mating_date, + -- 计算配后天数:孕检日期 - 配种日期 + CASE + WHEN COALESCE(br.create_time, sf.mating_date) IS NOT NULL + THEN DATEDIFF(pr.datetime, COALESCE(br.create_time, sf.mating_date)) + ELSE NULL + END as days_after_mating from sc_pregnancy_record pr left join sheep_file sf on pr.sheep_id = sf.id - left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value and mating_type.dict_type = 'breed_type' and mating_type.status = '0' - left join da_ranch r on sf.ranch_id = r.id - left join sheep_file father_sf on sf.bs_father_id = father_sf.id + -- 关联配种记录表,获取最新的配种记录 + left join ( + select br1.* + from sc_breed_record br1 + inner join ( + select ewe_id, max(create_time) as max_time + from sc_breed_record + group by ewe_id + ) br2 on br1.ewe_id = br2.ewe_id and br1.create_time = br2.max_time + ) br on sf.id = br.ewe_id + -- 关联公羊信息 + left join sheep_file ram_sf on br.ram_id = ram_sf.id + -- 关联配种类型字典 + left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value + and mating_type.dict_type = 'breed_type' and mating_type.status = '0' + + + insert into sc_pregnancy_record @@ -153,8 +191,6 @@ technician = #{technician}, way = #{way}, remark = #{remark}, - create_by = #{updateBy}, - create_time = #{updateTime}, where id = #{id} @@ -178,7 +214,6 @@ breed_status_id = #{breedStatusId}, expected_date = #{expectedDate}, gestation_day = #{gestationDay}, - create_time = now() where id = #{sheepId} diff --git a/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml b/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml index baedeeb..71c1458 100644 --- a/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml @@ -44,6 +44,7 @@ and comment = #{comment} and is_delete = #{isDelete} + order by create_time desc - + @@ -131,4 +144,14 @@ #{id} + + + + UPDATE sheep_file + SET breed = #{status}, + update_time = NOW() + WHERE id = #{sheepId} + AND is_delete = 0 + + \ No newline at end of file From d9d489c1a0989b7e51df2343d8b605bcf1911b43 Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 24 Aug 2025 12:17:22 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E6=AD=BB?= =?UTF-8?q?=E4=BA=A1=E6=A8=A1=E5=9D=97=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=9C=A8=E7=BE=A4=E4=B8=8D=E5=9C=A8=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../breed/mapper/ScSheepDeathMapper.java | 13 ++++++-- .../service/impl/ScSheepDeathServiceImpl.java | 32 +++++++++++++++++-- .../produce/breed/ScSheepDeathMapper.xml | 13 ++++++-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScSheepDeathMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScSheepDeathMapper.java index db7647c..853ab39 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScSheepDeathMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/mapper/ScSheepDeathMapper.java @@ -70,11 +70,20 @@ public interface ScSheepDeathMapper public int deleteScSheepDeathByIds(Long[] ids); /** - * 更新羊只状态 + * 更新羊只繁育状态 * * @param sheepId 羊只ID - * @param status 状态 + * @param status 繁育状态 * @return 更新结果 */ public int updateSheepFileStatus(@Param("sheepId") Long sheepId, @Param("status") String status); + + /** + * 新增:更新羊只在群状态 + * + * @param sheepId 羊只ID + * @param status 在群状态(1-在群,2-不在群) + * @return 更新结果 + */ + public int updateSheepStatus(@Param("sheepId") Long sheepId, @Param("status") String status); } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java index 12e7afd..6db1659 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java @@ -111,7 +111,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) { Map sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags()); if (sheepInfo != null) { - scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null); + Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null; + scSheepDeath.setSheepId(sheepId); + + // 插入死淘记录后,同时更新羊只在群状态为"不在群"(字典值为2) + if (sheepId != null) { + scSheepDeathMapper.updateSheepStatus(sheepId, "2"); + } } } @@ -132,7 +138,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) { Map sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags()); if (sheepInfo != null) { - scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null); + Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null; + scSheepDeath.setSheepId(sheepId); + + // 修改死淘记录时,同时更新羊只在群状态为"不在群"(字典值为2) + if (sheepId != null) { + scSheepDeathMapper.updateSheepStatus(sheepId, "2"); + } } } @@ -149,6 +161,15 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService @Override public int deleteScSheepDeathByIds(Long[] ids) { + // 可选:删除死淘记录前,将对应羊只在群状态改回"在群" + for (Long id : ids) { + ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id); + if (scSheepDeath != null && scSheepDeath.getSheepId() != null) { + // 恢复羊只在群状态为"在群"(字典值为1) + scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1"); + } + } + return scSheepDeathMapper.deleteScSheepDeathByIds(ids); } @@ -161,6 +182,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService @Override public int deleteScSheepDeathById(Long id) { + // 可选:删除死淘记录前,将对应羊只在群状态改回"在群" + ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id); + if (scSheepDeath != null && scSheepDeath.getSheepId() != null) { + // 恢复羊只在群状态为"在群"(字典值为1) + scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1"); + } + return scSheepDeathMapper.deleteScSheepDeathById(id); } } \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml b/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml index 71c1458..1444e04 100644 --- a/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/breed/ScSheepDeathMapper.xml @@ -52,7 +52,7 @@ where id = #{id} - + + insert into sw_treatment @@ -76,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" disease_pid, veterinary, usage_id, + status, comment, update_by, update_time, @@ -98,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{diseasePid}, #{veterinary}, #{usageId}, + #{status}, #{comment}, #{updateBy}, #{updateTime}, @@ -110,14 +117,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into sw_treatment (diag_id, sheep_id, variety, sheep_type, month_age, gender, parity, breed, lact_day, gest_day, datetime, - disease_id, disease_pid, veterinary, usage_id, + disease_id, disease_pid, veterinary, usage_id,status , comment, update_by, update_time, create_by, create_time) values (#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType}, #{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed}, #{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId}, - #{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.comment}, + #{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment}, #{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime}) @@ -140,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" disease_pid = #{diseasePid}, veterinary = #{veterinary}, usage_id = #{usageId}, + status = #{status}, comment = #{comment}, update_by = #{updateBy}, update_time = #{updateTime},