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 01/15] =?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
@@ -51,11 +52,23 @@
where id = #{id}
-
+
- select id as sheepId, variety, name as sheepType, gender, day_age as dayAge, parity, sheepfold_name as sheepfoldName, breed as breedStatus, post_lambing_day as postLambingDay, lactation_day as lactationDay, gestation_day as gestationDay
+ select
+ id as sheepId,
+ variety,
+ name as sheepType,
+ gender,
+ day_age as dayAge,
+ parity,
+ sheepfold_name as sheepfoldName,
+ breed as breedStatus,
+ post_lambing_day as postLambingDay,
+ lactation_day as lactationDay,
+ gestation_day as gestationDay
from sheep_file
where bs_manage_tags = #{manageTags} and is_delete = 0
+ limit 1
@@ -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 05/15] =?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}
-
+
select
id as sheepId,
@@ -145,7 +145,7 @@
-
+
UPDATE sheep_file
SET breed = #{status},
@@ -154,4 +154,13 @@
AND is_delete = 0
+
+
+ UPDATE sheep_file
+ SET status = #{status},
+ update_time = NOW()
+ WHERE id = #{sheepId}
+ AND is_delete = 0
+
+
\ No newline at end of file
From 12da9cf3a0c6327d78e4b250d2c032df3c3d4127 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=BC=82=E6=B3=8A?= <1913856125@qq.com>
Date: Sun, 24 Aug 2025 18:23:16 +0800
Subject: [PATCH 06/15] =?UTF-8?q?=E4=BF=AE=E6=94=B92.0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/zhyc/common/utils/DateUtils.java | 1 +
.../module/base/mapper/BasSheepMapper.java | 2 +
.../controller/DiagnosisController.java | 1 -
.../domain/SwMedicineUsageDetails.java | 8 ++
.../module/biosafety/domain/Treatment.java | 4 +
.../biosafety/mapper/TreatmentMapper.java | 3 +
.../service/impl/DiagnosisServiceImpl.java | 84 +++++++++++++++++--
.../service/impl/TreatmentServiceImpl.java | 25 +++++-
.../service/impl/ScSheepDeathServiceImpl.java | 18 ++++
.../biosafety/SwMedicineUsageMapper.xml | 7 +-
.../mapper/biosafety/TreatmentMapper.xml | 14 +++-
11 files changed, 153 insertions(+), 14 deletions(-)
diff --git a/zhyc-common/src/main/java/com/zhyc/common/utils/DateUtils.java b/zhyc-common/src/main/java/com/zhyc/common/utils/DateUtils.java
index c95401e..0570896 100644
--- a/zhyc-common/src/main/java/com/zhyc/common/utils/DateUtils.java
+++ b/zhyc-common/src/main/java/com/zhyc/common/utils/DateUtils.java
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
+import java.time.temporal.ChronoUnit;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/mapper/BasSheepMapper.java b/zhyc-module/src/main/java/com/zhyc/module/base/mapper/BasSheepMapper.java
index 4baaf89..a953f9a 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/base/mapper/BasSheepMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/base/mapper/BasSheepMapper.java
@@ -3,6 +3,7 @@ package com.zhyc.module.base.mapper;
import java.util.List;
import com.zhyc.module.base.domain.BasSheep;
+import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
@@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
* @author ruoyi
* @date 2025-07-15
*/
+@Mapper
public interface BasSheepMapper
{
/**
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/controller/DiagnosisController.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/controller/DiagnosisController.java
index 20224ad..3b7aff6 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/controller/DiagnosisController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/controller/DiagnosisController.java
@@ -88,7 +88,6 @@ public class DiagnosisController extends BaseController
@PostMapping("/adds")
public AjaxResult adds(@RequestBody Diagnosis diagnosis)
{
- System.out.println(diagnosis);
return toAjax(diagnosisService.insertDiagnosisList(diagnosis));
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsageDetails.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsageDetails.java
index 34e0423..1b67654 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsageDetails.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsageDetails.java
@@ -1,11 +1,14 @@
package com.zhyc.module.biosafety.domain;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
+import java.util.Date;
+
/**
* 药品使用记录详情对象 sw_medicine_usage_details
*
@@ -46,6 +49,11 @@ public class SwMedicineUsageDetails extends BaseEntity
@Excel(name = "使用方法")
private String usageId;
+ /** 使用时间 */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+ private Date usetime;
+
/** 生产厂家 */
@Excel(name = "生产厂家")
private String manufacturer;
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Treatment.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Treatment.java
index ae2d1a0..653dc53 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Treatment.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Treatment.java
@@ -89,6 +89,10 @@ public class Treatment extends BaseEntity
/** 兽医 */
@Excel(name = "兽医")
private String veterinary;
+ /** 治疗状态 */
+ @Excel(name = "治疗状态")
+ private String status;
+
/** 药品使用记录id */
@Excel(name = "药品使用记录id")
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/mapper/TreatmentMapper.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/mapper/TreatmentMapper.java
index 643d9a0..1d48767 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/mapper/TreatmentMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/mapper/TreatmentMapper.java
@@ -63,4 +63,7 @@ public interface TreatmentMapper
public int deleteTreatmentByIds(Long[] ids);
int insertTreatmentList(List treatments);
+
+
+ List selectTreatmentStatus(Long sheepId);
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/DiagnosisServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/DiagnosisServiceImpl.java
index ffa1e60..8447684 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/DiagnosisServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/DiagnosisServiceImpl.java
@@ -1,5 +1,6 @@
package com.zhyc.module.biosafety.service.impl;
+import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -9,13 +10,18 @@ import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.SheepFileMapper;
+import com.zhyc.module.biosafety.domain.Treatment;
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
+import com.zhyc.module.biosafety.mapper.TreatmentMapper;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.biosafety.domain.Diagnosis;
import com.zhyc.module.biosafety.service.IDiagnosisService;
import org.springframework.transaction.annotation.Transactional;
+
+
/**
* 诊疗结果Service业务层处理
*
@@ -31,6 +37,8 @@ public class DiagnosisServiceImpl implements IDiagnosisService
private SheepFileMapper sheepFileMapper;
@Autowired
private BasSheepMapper sheepMapper;
+ @Autowired
+ private TreatmentMapper treatmentMapper;
/**
* 查询诊疗结果
@@ -75,11 +83,24 @@ public class DiagnosisServiceImpl implements IDiagnosisService
String username = SecurityUtils.getLoginUser().getUser().getNickName();
diagnosis.setCreateBy(username);
diagnosis.setCreateTime(DateUtils.getNowDate());
- if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())){
- BasSheep basSheep = new BasSheep();
- basSheep.setId(diagnosis.getSheepId());
- basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
- sheepMapper.updateBasSheep(basSheep);
+
+ if (diagnosis.getSheepfoldId() != null)
+ if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())) {
+ BasSheep basSheep = new BasSheep();
+ basSheep.setId(diagnosis.getSheepId());
+ basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
+ sheepMapper.updateBasSheep(basSheep);
+ }
+
+// 更改治疗记录的状态
+ Treatment treatment = new Treatment();
+ treatment.setId(diagnosis.getTreatId());
+ if (diagnosis.getResult().equals("0")){
+ treatment.setStatus("-1");
+ treatmentMapper.updateTreatment(treatment);
+ }else if (diagnosis.getResult().equals("1")){
+ treatment.setStatus("2");
+ treatmentMapper.updateTreatment(treatment);
}
// 转入其他羊舍
return diagnosisMapper.insertDiagnosis(diagnosis);
@@ -87,9 +108,60 @@ public class DiagnosisServiceImpl implements IDiagnosisService
@Override
+ @Transactional
public int insertDiagnosisList(Diagnosis diagnosis) {
+ if (diagnosis.getTreatIds() != null && diagnosis.getTreatIds().length > 0){
+ for (Integer treatId : diagnosis.getTreatIds()) {
+ System.out.println(treatId);
+ Treatment treatment = treatmentMapper.selectTreatmentById(Long.valueOf(treatId));
+ System.out.println(treatment);
+// BasSheep basSheep = sheepMapper.selectBasSheepById(treatment.getSheepId());
- return 0;
+ Diagnosis diag = new Diagnosis();
+ BeanUtils.copyProperties(treatment,diag);
+ diag.setResult(diagnosis.getResult());
+ diag.setParity(String.valueOf(treatment.getParity()));
+
+
+ // treatment 和 diagnosis 是你的两个实体对象
+ Date start = treatment.getDatetime(); // 已经是 Date
+ Date end = diagnosis.getDatetime(); // 已经是 Date
+ diag.setBegindate(start);
+ diag.setEnddate(end);
+ long oneDayMillis = 24 * 60 * 60 * 1000L;
+ long days = (end.getTime() / oneDayMillis) - (start.getTime() / oneDayMillis);
+ if (days<0){
+ days=0;
+ }
+
+ diag.setTreatDay(days);
+ diag.setTreatId(treatment.getId());
+
+
+ String username = SecurityUtils.getLoginUser().getUser().getNickName();
+ diag.setCreateBy(username);
+ diag.setCreateTime(DateUtils.getNowDate());
+ diagnosisMapper.insertDiagnosis(diag);
+ treatment.setDiagId(diag.getId());
+
+ // 更改治疗记录的状态
+ if (diagnosis.getResult().equals("0")){
+ treatment.setStatus("-1");
+ treatmentMapper.updateTreatment(treatment);
+ }else if (diagnosis.getResult().equals("1")){
+ treatment.setStatus("2");
+ treatmentMapper.updateTreatment(treatment);
+ }
+ if (diagnosis.getSheepfoldId() != null){
+ BasSheep basSheep = new BasSheep();
+ basSheep.setId(diagnosis.getSheepId());
+ basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
+ sheepMapper.updateBasSheep(basSheep);
+ }
+ }
+ }
+
+ return 1;
}
/**
diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/TreatmentServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/TreatmentServiceImpl.java
index 1f5c6ab..abb7d57 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/TreatmentServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/service/impl/TreatmentServiceImpl.java
@@ -7,8 +7,10 @@ import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils;
import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.SheepFileMapper;
+import com.zhyc.module.biosafety.domain.Diagnosis;
import com.zhyc.module.biosafety.domain.SwMedicineUsage;
import com.zhyc.module.biosafety.domain.SwMedicineUsageDetails;
+import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
import com.zhyc.module.biosafety.mapper.SwMedicineUsageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -34,6 +36,8 @@ public class TreatmentServiceImpl implements ITreatmentService
private SwMedicineUsageMapper medicineUsageMapper;
@Autowired
private SheepFileMapper sheepFileMapper;
+ @Autowired
+ private DiagnosisMapper diagnosisMapper;
/**
* 查询治疗记录
@@ -47,7 +51,9 @@ public class TreatmentServiceImpl implements ITreatmentService
Treatment treatment = treatmentMapper.selectTreatmentById(id);
// 获取药品使用记录
SwMedicineUsage swMedicineUsage = medicineUsageService.selectSwMedicineUsageById(treatment.getUsageId());
- treatment.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
+ if (swMedicineUsage!=null){
+ treatment.setUsageDetails(swMedicineUsage.getSwMedicineUsageDetailsList());
+ }
return treatment;
}
@@ -176,4 +182,21 @@ public class TreatmentServiceImpl implements ITreatmentService
{
return treatmentMapper.deleteTreatmentById(id);
}
+
+ public void updateTreatmentStatus(Long sheepId) {
+ List treatments=treatmentMapper.selectTreatmentStatus(sheepId);
+ Diagnosis diagnosis = new Diagnosis();
+ for (Treatment treatment : treatments) {
+ if (treatment.getDiagId()!=null){
+ diagnosis.setId(treatment.getDiagId());
+ diagnosis.setResult("-1");
+ diagnosisMapper.updateDiagnosis(diagnosis);
+ if (treatment.getDiagId()!=null){
+ Treatment treat = new Treatment();
+ treat.setId(treatment.getId());
+ treatmentMapper.updateTreatment(treat);
+ }
+ }
+ }
+ }
}
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 15ead5a..0d67390 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
@@ -3,11 +3,17 @@ package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import java.util.Map;
import com.zhyc.common.utils.DateUtils;
+import com.zhyc.module.biosafety.domain.Diagnosis;
+import com.zhyc.module.biosafety.domain.Treatment;
+import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
+import com.zhyc.module.biosafety.mapper.TreatmentMapper;
+import com.zhyc.module.biosafety.service.impl.TreatmentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.breed.mapper.ScSheepDeathMapper;
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
+import org.springframework.transaction.annotation.Transactional;
/**
* 羊只死淘记录Service业务层处理
@@ -20,6 +26,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
{
@Autowired
private ScSheepDeathMapper scSheepDeathMapper;
+ @Autowired
+ private DiagnosisMapper diagnosisMapper;
+ @Autowired
+ private TreatmentServiceImpl treatmentService;
+
+
+
/**
* 查询羊只死淘记录
@@ -100,6 +113,7 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
* @return 结果
*/
@Override
+ @Transactional
public int insertScSheepDeath(ScSheepDeath scSheepDeath)
{
// 设置事件类型默认为"死亡"
@@ -110,11 +124,15 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
// 如果有管理耳号,查询并设置羊只ID
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);
}
}
+
+ treatmentService.updateTreatmentStatus(scSheepDeath.getSheepId());
scSheepDeath.setCreateTime(DateUtils.getNowDate());
+
return scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
}
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml
index e767362..f478719 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/SwMedicineUsageMapper.xml
@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
@@ -63,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select smud.id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number,
+ select smud.id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number,
sm.name
from sw_medicine_usage_details smud
join sw_medicine sm on smud.medi_id = sm.id
@@ -133,9 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId, manufacturer, batch_number) values
+ insert into sw_medicine_usage_details( id, medi_usage, medi_id, dosage, unit, usageId,usetime, manufacturer, batch_number) values
- ( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.manufacturer}, #{item.batchNumber})
+ ( #{item.id}, #{item.mediUsage}, #{item.mediId}, #{item.dosage}, #{item.unit}, #{item.usageId}, #{item.usetime},#{item.manufacturer}, #{item.batchNumber})
\ No newline at end of file
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
index 031bb74..5e07a30 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
@@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
@@ -32,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
+ select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id,status, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
bs.manage_tags,
sd.name disease_name,
sd2.name disease_pname
@@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and sheep_id = #{sheepId}
and datetime between #{params.beginDatetime} and #{params.endDatetime}
and disease_id = #{diseaseId}
+ and status = #{status}
and veterinary = #{veterinary}
ORDER BY datetime DESC
@@ -57,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where t.id = #{id}
+
+ select * from sw_treatment where sheep_id = #{sheepId} and status in (0, 1)
+
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},
From 02d95fc51fc98de8a25b4884a47f04b1daa4f8c5 Mon Sep 17 00:00:00 2001
From: HashMap
Date: Sun, 24 Aug 2025 23:40:21 +0800
Subject: [PATCH 07/15] =?UTF-8?q?feat(module):=20=E9=A5=B2=E5=96=82?=
=?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
+ 添加量饲喂量统计功能
+ 解决了其他两个页面的若干逻辑错误
+ 优化了配料清单的缓存结构:
+ 将缓存和同步过程移动到Service层, 以便其他模块调用
---
.../feed/controller/SgFeedListController.java | 110 +----------
.../controller/SgFeedStatisticController.java | 129 +++++++++++++
.../module/feed/domain/SgFeedStatistic.java | 98 ++++++++++
.../module/feed/domain/SgFormulaList.java | 15 +-
.../feed/mapper/SgFeedStatisticMapper.java | 63 +++++++
.../TypeHandler/DaSheepfoldHandler.java | 38 ++++
.../mapper/TypeHandler/JsonTypeHandler.java | 42 +++++
.../TypeHandler/SgFormulaListHandler.java | 37 ++++
.../feed/service/ISgFeedListService.java | 6 +-
.../feed/service/ISgFeedStatisticService.java | 65 +++++++
.../service/impl/SgFeedListServiceImpl.java | 126 +++++++++++--
.../impl/SgFeedStatisticServiceImpl.java | 176 ++++++++++++++++++
.../mapper/feed/SgFeedListMapper.xml | 1 +
.../mapper/feed/SgFeedStatisticMapper.xml | 100 ++++++++++
14 files changed, 881 insertions(+), 125 deletions(-)
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedStatisticController.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedStatistic.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedStatisticMapper.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/DaSheepfoldHandler.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/JsonTypeHandler.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/SgFormulaListHandler.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedStatisticService.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
create mode 100644 zhyc-module/src/main/resources/mapper/feed/SgFeedStatisticMapper.xml
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
index 446327d..895f061 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
@@ -1,15 +1,10 @@
package com.zhyc.module.feed.controller;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.servlet.http.HttpServletResponse;
-import com.zhyc.module.feed.domain.SgFeedPlan;
-import com.zhyc.module.feed.domain.SgFormulaManagement;
-import com.zhyc.module.feed.service.ISgFeedPlanService;
-import com.zhyc.module.feed.service.ISgFormulaManagementService;
+import com.zhyc.module.feed.service.impl.SgFeedListServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
@@ -41,19 +36,12 @@ import com.zhyc.common.core.page.TableDataInfo;
public class SgFeedListController extends BaseController {
private final ISgFeedListService sgFeedListService;
- private final ISgFormulaManagementService sgFormulaManagementService;
-
- private final ISgFeedPlanService sgFeedPlanService;
-
- private final Map sgFeedListMap = new HashMap<>();
public static boolean refresh = true;
@Autowired
- public SgFeedListController(ISgFeedListService sgFeedListService, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
+ public SgFeedListController(ISgFeedListService sgFeedListService) {
this.sgFeedListService = sgFeedListService;
- this.sgFormulaManagementService = sgFormulaManagementService;
- this.sgFeedPlanService = sgFeedPlanService;
}
/**
@@ -68,7 +56,7 @@ public class SgFeedListController extends BaseController {
当配方管理表出现更新 或 饲喂计划表出现增删改时会将refresh置为true 通知此处进行刷新
*/
if (refresh) {
- SyncFeedList();
+ sgFeedListService.SyncFeedList();
refresh = false;
}
startPage();
@@ -78,7 +66,7 @@ public class SgFeedListController extends BaseController {
for (SgFeedList item : list) {
String key = item.getFormulaId() + "_" + item.getFormulaBatchId();
// 从缓存中取出完整对象
- SgFeedList itemInCache = sgFeedListMap.getOrDefault(key, item);
+ SgFeedList itemInCache = SgFeedListServiceImpl.getSgFeedListMap().getOrDefault(key, item);
// 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
itemInCache.setId(item.getId());
itemInCache.setFormulaBatchId(item.getFormulaBatchId());
@@ -143,94 +131,4 @@ public class SgFeedListController extends BaseController {
return toAjax(sgFeedListService.deleteSgFeedListByIds(ids));
}
-
- public void SyncFeedList() {
- // 清空旧缓存
- sgFeedListMap.clear();
- // 获取配方管理和现有配料清单内容
- List formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
- List feedLists = sgFeedListService.selectSgFeedListList(new SgFeedList());
- // 将最新查询的配料清单加入缓存
- for (SgFeedList sgFeedList : feedLists) {
- sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
- }
- // 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
- for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
- // 匹配 但忽略模板配方
- if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
- // 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
- boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
- // 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
- boolean isPlan = true;
- // 设置缓存对象具体值
- SgFeedList sgFeedList = new SgFeedList();
- sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
- sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
- sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
- sgFeedList.setRootFormula(sgFormulaManagement);
-
-
- // 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
- SgFeedPlan rootPlanQuery = new SgFeedPlan();
- rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
- rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
- List sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
- // 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
- if (sgFeedPlans.isEmpty()) {
- isPlan = false;
- } else {
- // rootPlan中存储的是该配方批号的总量
- SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
-
- // 将计划实体对象设置到配料清单中
- sgFeedList.setRootPlan(rootPlan);
-
- // 完整的配料清单对象加入缓存
- sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
- }
-
- // 不存在则插入
- if (!isExist && isPlan) {
- sgFeedListService.insertSgFeedList(sgFeedList);
- }
- }
- }
- }
-
- /**
- * 计算某个配方某个批次的总和值
- *
- * @param sgFeedPlans 配方计划列表
- * @return 各个值总和
- */
- private static SgFeedPlan computePlanTotal(List sgFeedPlans) {
- SgFeedPlan rootPlan = new SgFeedPlan();
- if (!sgFeedPlans.isEmpty()) {
- int sheepCountTotal = 0;
- double sheepDailySize = 0.0;
- double planFeedMorningSize = 0.0;
- double planFeedNoonSize = 0.0;
- double planFeedAfternoonSize = 0.0;
- double planFeedTotalSize = 0.0;
- for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
- sheepCountTotal += sgFeedPlan.getSheepCount();
- sheepDailySize += sgFeedPlan.getPlanDailySize();
- planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
- planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
- planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
- planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
- }
-
- rootPlan.setSheepCount(sheepCountTotal);
- rootPlan.setPlanDailySize(sheepDailySize);
- rootPlan.setPlanMorningSize(planFeedMorningSize);
- rootPlan.setPlanNoonSize(planFeedNoonSize);
- rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
- rootPlan.setPlanFeedTotal(planFeedTotalSize);
-
- // 设置计划日期
- rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
- }
- return rootPlan;
- }
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedStatisticController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedStatisticController.java
new file mode 100644
index 0000000..de0334f
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedStatisticController.java
@@ -0,0 +1,129 @@
+package com.zhyc.module.feed.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.zhyc.common.utils.uuid.UUID;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.zhyc.common.annotation.Log;
+import com.zhyc.common.core.controller.BaseController;
+import com.zhyc.common.core.domain.AjaxResult;
+import com.zhyc.common.enums.BusinessType;
+import com.zhyc.module.feed.domain.SgFeedStatistic;
+import com.zhyc.module.feed.service.ISgFeedStatisticService;
+import com.zhyc.common.utils.poi.ExcelUtil;
+import com.zhyc.common.core.page.TableDataInfo;
+
+/**
+ * 饲喂量统计Controller
+ *
+ * @author HashMap
+ * @date 2025-08-23
+ */
+@RestController
+@RequestMapping("/feed/FeedStatistic")
+@Transactional(rollbackFor = Exception.class)
+public class SgFeedStatisticController extends BaseController {
+ private final ISgFeedStatisticService sgFeedStatisticService;
+
+
+
+ public SgFeedStatisticController(ISgFeedStatisticService sgFeedStatisticService) {
+ this.sgFeedStatisticService = sgFeedStatisticService;
+ }
+
+ /**
+ * 查询饲喂量统计列表
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(SgFeedStatistic sgFeedStatistic) {
+ startPage();
+ List list = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
+ return getDataTable(list);
+ }
+
+ /**
+ * 导出饲喂量统计列表
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:export')")
+ @Log(title = "饲喂量统计", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, SgFeedStatistic sgFeedStatistic) {
+ List list = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
+ ExcelUtil util = new ExcelUtil<>(SgFeedStatistic.class);
+ util.exportExcel(response, list, "饲喂量统计数据");
+ }
+
+ /**
+ * 获取饲喂量统计详细信息
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:query')")
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") String id) {
+ return success(sgFeedStatisticService.selectSgFeedStatisticById(id));
+ }
+
+ /**
+ * 新增饲喂量统计
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:add')")
+ @Log(title = "饲喂量统计", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody SgFeedStatistic sgFeedStatistic) {
+ if (null == sgFeedStatistic.getFormulaId() && null == sgFeedStatistic.getFormulaBatchId()) {
+ throw new RuntimeException("ERROR: 数据为空");
+ }
+ List isExist = sgFeedStatisticService.selectSgFeedStatisticList(sgFeedStatistic);
+ if (null != isExist && !isExist.isEmpty()) {
+ throw new RuntimeException("WARNING: 数据重复");
+ }
+ // 设定唯一标识符主键
+ sgFeedStatistic.setId(UUID.randomUUID().toString());
+ /*
+ * 初始化数据
+ * 弃用: 此处不再需要初始化,前端选定批号后会触发预载, 此处再初始化会覆盖前端后续的自定义数据
+ */
+ // sgFeedStatisticService.getInitSgFeedStatistic(sgFeedStatistic);
+ return toAjax(sgFeedStatisticService.insertSgFeedStatistic(sgFeedStatistic));
+ }
+
+ /**
+ * 修改饲喂量统计
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:edit')")
+ @Log(title = "饲喂量统计", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody SgFeedStatistic sgFeedStatistic) {
+ return toAjax(sgFeedStatisticService.updateSgFeedStatistic(sgFeedStatistic));
+ }
+
+ /**
+ * 删除饲喂量统计
+ */
+ @PreAuthorize("@ss.hasPermi('feed:FeedStatistic:remove')")
+ @Log(title = "饲喂量统计", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{ids}")
+ public AjaxResult remove(@PathVariable String[] ids) {
+ return toAjax(sgFeedStatisticService.deleteSgFeedStatisticByIds(ids));
+ }
+
+ @GetMapping("/init")
+ public TableDataInfo getInitData(SgFeedStatistic sgFeedStatistic){
+ sgFeedStatisticService.getInitSgFeedStatistic(sgFeedStatistic);
+ // 兼容写法 - 实际只是为了返回一个 sgFeedStatistic
+ List list = new ArrayList<>();
+ list.add(sgFeedStatistic);
+ return getDataTable(list);
+ }
+}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedStatistic.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedStatistic.java
new file mode 100644
index 0000000..2cdc21e
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedStatistic.java
@@ -0,0 +1,98 @@
+package com.zhyc.module.feed.domain;
+
+import com.alibaba.fastjson2.JSON;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zhyc.module.base.domain.DaSheepfold;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.zhyc.common.annotation.Excel;
+import com.zhyc.common.core.domain.BaseEntity;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 饲喂量统计对象 sg_feed_statistic
+ *
+ * @author HashMap
+ * @date 2025-08-23
+ */
+@Setter
+@Getter
+public class SgFeedStatistic extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * UUID
+ */
+ private String id;
+
+ /**
+ * 配方编号
+ */
+ @Excel(name = "配方编号")
+ private String formulaId;
+
+ /**
+ * 配方批号
+ */
+ @Excel(name = "配方批号")
+ private String formulaBatchId;
+
+ /**
+ * 羊只数量
+ */
+ @Excel(name = "羊只数量")
+ private Long sheepFoldCount;
+
+ /**
+ * 青贮损耗比例
+ */
+ @Excel(name = "青贮损耗比例")
+ private String silageLossRate;
+
+ /**
+ * 总饲喂量
+ */
+ @Excel(name = "总饲喂量")
+ private Double feedTotalSize;
+
+ /**
+ * 日均饲喂量
+ */
+ @Excel(name = "日均饲喂量")
+ private Double feedDailySize;
+
+ /**
+ * 配方列表
+ */
+ @Excel(name = "配方列表")
+ private List materialList;
+
+ /**
+ * 羊舍列表
+ */
+ @Excel(name = "羊舍列表")
+ private List sheepFoldList;
+
+ @Excel(name = "日期")
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ private Date feedDate;
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+ .append("id", getId())
+ .append("formulaId", getFormulaId())
+ .append("formulaBatchId", getFormulaBatchId())
+ .append("sheepFoldCount", getSheepFoldCount())
+ .append("silageLossRate", getSilageLossRate())
+ .append("feedTotalSize", getFeedTotalSize())
+ .append("feedDailySize", getFeedDailySize())
+ .append("materialList", getMaterialList())
+ .append("sheepFoldList", getSheepFoldList())
+ .toString();
+ }
+}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java
index 03ab542..aac1fc9 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFormulaList.java
@@ -39,14 +39,25 @@ public class SgFormulaList extends BaseEntity
@Excel(name = "比例")
private Long ratio;
- /** 颗粒原料 */
+ /**
+ * 颗粒原料
+ * 当前不局限于 "是否颗粒原料" 而且多种类型的标识符
+ */
@Excel(name = "颗粒原料")
private String isGranular;
- /** 补饲 */
+ /**
+ * 补饲
+ * 当前用作饲喂类型标识
+ */
@Excel(name = "补饲")
private String isSupplement;
+ /**
+ * 添加量 - 供其他一些统计模块使用
+ */
+ private Double feedSize;
+
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedStatisticMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedStatisticMapper.java
new file mode 100644
index 0000000..abee631
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedStatisticMapper.java
@@ -0,0 +1,63 @@
+package com.zhyc.module.feed.mapper;
+
+import java.util.List;
+import com.zhyc.module.feed.domain.SgFeedStatistic;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 饲喂量统计Mapper接口
+ *
+ * @author HashMap
+ * @date 2025-08-23
+ */
+@Mapper
+public interface SgFeedStatisticMapper
+{
+ /**
+ * 查询饲喂量统计
+ *
+ * @param id 饲喂量统计主键
+ * @return 饲喂量统计
+ */
+ SgFeedStatistic selectSgFeedStatisticById(String id);
+
+ /**
+ * 查询饲喂量统计列表
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 饲喂量统计集合
+ */
+ List selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 新增饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 修改饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 删除饲喂量统计
+ *
+ * @param id 饲喂量统计主键
+ * @return 结果
+ */
+ int deleteSgFeedStatisticById(String id);
+
+ /**
+ * 批量删除饲喂量统计
+ *
+ * @param ids 需要删除的数据主键集合
+ * @return 结果
+ */
+ int deleteSgFeedStatisticByIds(String[] ids);
+}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/DaSheepfoldHandler.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/DaSheepfoldHandler.java
new file mode 100644
index 0000000..af89abc
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/DaSheepfoldHandler.java
@@ -0,0 +1,38 @@
+package com.zhyc.module.feed.mapper.TypeHandler;
+
+import com.alibaba.fastjson2.JSON;
+import com.zhyc.module.base.domain.DaSheepfold;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+@MappedTypes(List.class)
+public class DaSheepfoldHandler extends BaseTypeHandler> {
+ @Override
+ public void setNonNullParameter(PreparedStatement ps, int i,
+ List parameter, JdbcType jdbcType) throws SQLException {
+ ps.setString(i, JSON.toJSONString(parameter));
+ }
+
+ @Override
+ public List getNullableResult(ResultSet rs, String columnName) throws SQLException {
+ return JSON.parseArray(rs.getString(columnName), DaSheepfold.class);
+ }
+
+ @Override
+ public List getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+ return JSON.parseArray(rs.getString(columnIndex), DaSheepfold.class);
+ }
+
+ @Override
+ public List getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+ return JSON.parseArray(cs.getString(columnIndex), DaSheepfold.class);
+ }
+}
+
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/JsonTypeHandler.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/JsonTypeHandler.java
new file mode 100644
index 0000000..dd0d22f
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/JsonTypeHandler.java
@@ -0,0 +1,42 @@
+package com.zhyc.module.feed.mapper.TypeHandler;
+
+import com.alibaba.fastjson2.JSON;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class JsonTypeHandler extends BaseTypeHandler {
+ private final Class type;
+
+ public JsonTypeHandler(Class type) {
+ this.type = type;
+ }
+
+ @Override
+ public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
+ ps.setString(i, JSON.toJSONString(parameter));
+ }
+
+ @Override
+ public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
+ String json = rs.getString(columnName);
+ return JSON.parseObject(json, type);
+ }
+
+ @Override
+ public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+ String json = rs.getString(columnIndex);
+ return JSON.parseObject(json, type);
+ }
+
+ @Override
+ public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+ String json = cs.getString(columnIndex);
+ return JSON.parseObject(json, type);
+ }
+}
+
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/SgFormulaListHandler.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/SgFormulaListHandler.java
new file mode 100644
index 0000000..10d857b
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/TypeHandler/SgFormulaListHandler.java
@@ -0,0 +1,37 @@
+package com.zhyc.module.feed.mapper.TypeHandler;
+
+import com.alibaba.fastjson2.JSON;
+import com.zhyc.module.feed.domain.SgFormulaList;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+@MappedTypes(List.class)
+public class SgFormulaListHandler extends BaseTypeHandler> {
+ @Override
+ public void setNonNullParameter(PreparedStatement ps, int i,
+ List parameter, JdbcType jdbcType) throws SQLException {
+ ps.setString(i, JSON.toJSONString(parameter));
+ }
+
+ @Override
+ public List getNullableResult(ResultSet rs, String columnName) throws SQLException {
+ return JSON.parseArray(rs.getString(columnName), SgFormulaList.class);
+ }
+
+ @Override
+ public List getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+ return JSON.parseArray(rs.getString(columnIndex), SgFormulaList.class);
+ }
+
+ @Override
+ public List getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+ return JSON.parseArray(cs.getString(columnIndex), SgFormulaList.class);
+ }
+}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedListService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedListService.java
index b293d84..b3c5a5f 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedListService.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedListService.java
@@ -1,6 +1,7 @@
package com.zhyc.module.feed.service;
import java.util.List;
+
import com.zhyc.module.feed.domain.SgFeedList;
/**
@@ -9,8 +10,7 @@ import com.zhyc.module.feed.domain.SgFeedList;
* @author HashMap
* @date 2025-08-19
*/
-public interface ISgFeedListService
-{
+public interface ISgFeedListService {
/**
* 查询配料清单
*
@@ -58,4 +58,6 @@ public interface ISgFeedListService
* @return 结果
*/
int deleteSgFeedListById(Long id);
+
+ void SyncFeedList();
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedStatisticService.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedStatisticService.java
new file mode 100644
index 0000000..9bdad7a
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/ISgFeedStatisticService.java
@@ -0,0 +1,65 @@
+package com.zhyc.module.feed.service;
+
+import java.util.List;
+import com.zhyc.module.feed.domain.SgFeedStatistic;
+
+/**
+ * 饲喂量统计Service接口
+ *
+ * @author HashMap
+ * @date 2025-08-23
+ */
+public interface ISgFeedStatisticService
+{
+ /**
+ * 查询饲喂量统计
+ *
+ * @param id 饲喂量统计主键
+ * @return 饲喂量统计
+ */
+ SgFeedStatistic selectSgFeedStatisticById(String id);
+
+ /**
+ * 查询饲喂量统计列表
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 饲喂量统计集合
+ */
+ List selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 新增饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 修改饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
+
+ /**
+ * 批量删除饲喂量统计
+ *
+ * @param ids 需要删除的饲喂量统计主键集合
+ * @return 结果
+ */
+ int deleteSgFeedStatisticByIds(String[] ids);
+
+ /**
+ * 删除饲喂量统计信息
+ *
+ * @param id 饲喂量统计主键
+ * @return 结果
+ */
+ int deleteSgFeedStatisticById(String id);
+
+ void getInitSgFeedStatistic(SgFeedStatistic sgFeedStatistic);
+
+
+}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
index 704d45d..225d851 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
@@ -1,7 +1,14 @@
package com.zhyc.module.feed.service.impl;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import com.zhyc.module.feed.domain.SgFeedPlan;
+import com.zhyc.module.feed.domain.SgFormulaManagement;
+import com.zhyc.module.feed.service.ISgFeedPlanService;
+import com.zhyc.module.feed.service.ISgFormulaManagementService;
+import lombok.Getter;
import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgFeedListMapper;
import com.zhyc.module.feed.domain.SgFeedList;
@@ -14,12 +21,17 @@ import com.zhyc.module.feed.service.ISgFeedListService;
* @date 2025-08-19
*/
@Service
-public class SgFeedListServiceImpl implements ISgFeedListService
-{
+public class SgFeedListServiceImpl implements ISgFeedListService {
private final SgFeedListMapper sgFeedListMapper;
+ private final ISgFormulaManagementService sgFormulaManagementService;
+ private final ISgFeedPlanService sgFeedPlanService;
+ @Getter
+ private final static Map sgFeedListMap = new HashMap<>();
- public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper) {
+ public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
this.sgFeedListMapper = sgFeedListMapper;
+ this.sgFormulaManagementService = sgFormulaManagementService;
+ this.sgFeedPlanService = sgFeedPlanService;
}
/**
@@ -29,8 +41,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 配料清单
*/
@Override
- public SgFeedList selectSgFeedListById(Long id)
- {
+ public SgFeedList selectSgFeedListById(Long id) {
return sgFeedListMapper.selectSgFeedListById(id);
}
@@ -41,8 +52,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 配料清单
*/
@Override
- public List selectSgFeedListList(SgFeedList sgFeedList)
- {
+ public List selectSgFeedListList(SgFeedList sgFeedList) {
return sgFeedListMapper.selectSgFeedListList(sgFeedList);
}
@@ -53,8 +63,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 结果
*/
@Override
- public int insertSgFeedList(SgFeedList sgFeedList)
- {
+ public int insertSgFeedList(SgFeedList sgFeedList) {
return sgFeedListMapper.insertSgFeedList(sgFeedList);
}
@@ -65,8 +74,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 结果
*/
@Override
- public int updateSgFeedList(SgFeedList sgFeedList)
- {
+ public int updateSgFeedList(SgFeedList sgFeedList) {
return sgFeedListMapper.updateSgFeedList(sgFeedList);
}
@@ -77,8 +85,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 结果
*/
@Override
- public int deleteSgFeedListByIds(Long[] ids)
- {
+ public int deleteSgFeedListByIds(Long[] ids) {
return sgFeedListMapper.deleteSgFeedListByIds(ids);
}
@@ -89,8 +96,97 @@ public class SgFeedListServiceImpl implements ISgFeedListService
* @return 结果
*/
@Override
- public int deleteSgFeedListById(Long id)
- {
+ public int deleteSgFeedListById(Long id) {
return sgFeedListMapper.deleteSgFeedListById(id);
}
+
+ public void SyncFeedList() {
+ // 清空旧缓存
+ sgFeedListMap.clear();
+ // 获取配方管理和现有配料清单内容
+ List formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
+ List feedLists = this.selectSgFeedListList(new SgFeedList());
+ // 将最新查询的配料清单加入缓存
+ for (SgFeedList sgFeedList : feedLists) {
+ sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
+ }
+ // 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
+ for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
+ // 匹配 但忽略模板配方
+ if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
+ // 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
+ boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
+ // 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
+ boolean isPlan = true;
+ // 设置缓存对象具体值
+ SgFeedList sgFeedList = new SgFeedList();
+ sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
+ sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
+ sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
+ sgFeedList.setRootFormula(sgFormulaManagement);
+
+
+ // 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
+ SgFeedPlan rootPlanQuery = new SgFeedPlan();
+ rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
+ rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
+ List sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
+ // 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
+ if (sgFeedPlans.isEmpty()) {
+ isPlan = false;
+ } else {
+ // rootPlan中存储的是该配方批号的总量
+ SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
+
+ // 将计划实体对象设置到配料清单中
+ sgFeedList.setRootPlan(rootPlan);
+
+ // 完整的配料清单对象加入缓存
+ sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
+ }
+
+ // 不存在则插入
+ if (!isExist && isPlan) {
+ this.insertSgFeedList(sgFeedList);
+ }
+ }
+ }
+ }
+
+ /**
+ * 计算某个配方某个批次的总和值
+ *
+ * @param sgFeedPlans 配方计划列表
+ * @return 各个值总和
+ */
+ private static SgFeedPlan computePlanTotal(List sgFeedPlans) {
+ SgFeedPlan rootPlan = new SgFeedPlan();
+ if (!sgFeedPlans.isEmpty()) {
+ int sheepCountTotal = 0;
+ double sheepDailySize = 0.0;
+ double planFeedMorningSize = 0.0;
+ double planFeedNoonSize = 0.0;
+ double planFeedAfternoonSize = 0.0;
+ double planFeedTotalSize = 0.0;
+ for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
+ sheepCountTotal += sgFeedPlan.getSheepCount();
+ sheepDailySize += sgFeedPlan.getPlanDailySize();
+ planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
+ planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
+ planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
+ planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
+ }
+
+ rootPlan.setSheepCount(sheepCountTotal);
+ rootPlan.setPlanDailySize(sheepDailySize);
+ rootPlan.setPlanMorningSize(planFeedMorningSize);
+ rootPlan.setPlanNoonSize(planFeedNoonSize);
+ rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
+ rootPlan.setPlanFeedTotal(planFeedTotalSize);
+
+ // 设置计划日期
+ rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
+ }
+ return rootPlan;
+ }
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
new file mode 100644
index 0000000..b1766bd
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
@@ -0,0 +1,176 @@
+package com.zhyc.module.feed.service.impl;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.zhyc.module.base.domain.DaSheepfold;
+import com.zhyc.module.feed.domain.SgFeedList;
+import com.zhyc.module.feed.domain.SgFeedPlan;
+import com.zhyc.module.feed.domain.SgFormulaList;
+import com.zhyc.module.feed.service.ISgFeedListService;
+import com.zhyc.module.feed.service.ISgFeedPlanService;
+import org.springframework.stereotype.Service;
+import com.zhyc.module.feed.mapper.SgFeedStatisticMapper;
+import com.zhyc.module.feed.domain.SgFeedStatistic;
+import com.zhyc.module.feed.service.ISgFeedStatisticService;
+
+/**
+ * 饲喂量统计Service业务层处理
+ *
+ * @author HashMap
+ * @date 2025-08-23
+ */
+@Service
+public class SgFeedStatisticServiceImpl implements ISgFeedStatisticService {
+ private final SgFeedStatisticMapper sgFeedStatisticMapper;
+
+ private final ISgFeedListService sgFeedListService;
+ private final ISgFeedPlanService sgFeedPlanService;
+
+ public SgFeedStatisticServiceImpl(SgFeedStatisticMapper sgFeedStatisticMapper, ISgFeedListService sgFeedListService, ISgFeedPlanService sgFeedPlanService) {
+ this.sgFeedStatisticMapper = sgFeedStatisticMapper;
+ this.sgFeedListService = sgFeedListService;
+ this.sgFeedPlanService = sgFeedPlanService;
+ }
+
+ /**
+ * 查询饲喂量统计
+ *
+ * @param id 饲喂量统计主键
+ * @return 饲喂量统计
+ */
+ @Override
+ public SgFeedStatistic selectSgFeedStatisticById(String id) {
+ return sgFeedStatisticMapper.selectSgFeedStatisticById(id);
+ }
+
+ /**
+ * 查询饲喂量统计列表
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 饲喂量统计
+ */
+ @Override
+ public List selectSgFeedStatisticList(SgFeedStatistic sgFeedStatistic) {
+ return sgFeedStatisticMapper.selectSgFeedStatisticList(sgFeedStatistic);
+ }
+
+ /**
+ * 新增饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ @Override
+ public int insertSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
+ return sgFeedStatisticMapper.insertSgFeedStatistic(sgFeedStatistic);
+ }
+
+ /**
+ * 修改饲喂量统计
+ *
+ * @param sgFeedStatistic 饲喂量统计
+ * @return 结果
+ */
+ @Override
+ public int updateSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
+ return sgFeedStatisticMapper.updateSgFeedStatistic(sgFeedStatistic);
+ }
+
+ /**
+ * 批量删除饲喂量统计
+ *
+ * @param ids 需要删除的饲喂量统计主键
+ * @return 结果
+ */
+ @Override
+ public int deleteSgFeedStatisticByIds(String[] ids) {
+ return sgFeedStatisticMapper.deleteSgFeedStatisticByIds(ids);
+ }
+
+ /**
+ * 删除饲喂量统计信息
+ *
+ * @param id 饲喂量统计主键
+ * @return 结果
+ */
+ @Override
+ public int deleteSgFeedStatisticById(String id) {
+ return sgFeedStatisticMapper.deleteSgFeedStatisticById(id);
+ }
+
+ /**
+ * 向待插入数据表单提供数据预载服务
+ *
+ * @param sgFeedStatistic 待填充的初始化数据
+ * @author ShiHan Wang
+ */
+ @Override
+ public void getInitSgFeedStatistic(SgFeedStatistic sgFeedStatistic) {
+ // 1. 查找饲料清单
+ SgFeedList sgFeedListQuery = new SgFeedList();
+ sgFeedListQuery.setFormulaId(sgFeedStatistic.getFormulaId());
+ sgFeedListQuery.setFormulaBatchId(sgFeedStatistic.getFormulaBatchId());
+
+ List feedLists = sgFeedListService.selectSgFeedListList(sgFeedListQuery);
+
+ if (!feedLists.isEmpty()) {
+ // 刷新缓存
+ sgFeedListService.SyncFeedList();
+
+ // 从缓存获取完整配方清单
+ String cacheKey = sgFeedStatistic.getFormulaId() + "_" + sgFeedStatistic.getFormulaBatchId();
+ SgFeedList sgFeedList = SgFeedListServiceImpl.getSgFeedListMap().get(cacheKey);
+
+ if (sgFeedList != null && sgFeedList.getFormulaList() != null) {
+ // 并行流式计算 提高性能
+ sgFeedList.getFormulaList().parallelStream().forEach(item -> {
+ double ratio = item.getRatio() / 100.0;
+ double feedSize = sgFeedList.getRootPlan().getPlanMorningSize() * ratio
+ + sgFeedList.getRootPlan().getPlanNoonSize() * ratio
+ + sgFeedList.getRootPlan().getPlanAfternoonSize() * ratio;
+ item.setFeedSize(feedSize);
+ });
+
+ // 统计总和
+ double totalFeedSize = sgFeedList.getFormulaList()
+ .parallelStream()
+ .mapToDouble(SgFormulaList::getFeedSize)
+ .sum();
+ sgFeedStatistic.setMaterialList(sgFeedList.getFormulaList());
+ sgFeedStatistic.setFeedTotalSize(totalFeedSize);
+ } else {
+ throw new RuntimeException("WARNING: 原料数据为空");
+ }
+ }
+
+ // 2. 查找饲喂计划并填充羊舍信息
+ SgFeedPlan sgFeedPlanQuery = new SgFeedPlan();
+ sgFeedPlanQuery.setFormulaId(sgFeedStatistic.getFormulaId());
+ sgFeedPlanQuery.setBatchId(sgFeedStatistic.getFormulaBatchId());
+
+ List sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlanQuery);
+
+ if (!sgFeedPlans.isEmpty()) {
+ // 并行计算提高查询性能
+ List sheepfolds = sgFeedPlans.parallelStream()
+ .map(plan -> {
+ DaSheepfold sheepfold = new DaSheepfold();
+ sheepfold.setId((long) plan.getSheepHouseId());
+ return sheepfold;
+ })
+ .collect(Collectors.toList());
+
+ long sheepCount = sgFeedPlans.parallelStream()
+ .mapToLong(SgFeedPlan::getSheepCount)
+ .sum();
+ sgFeedStatistic.setSheepFoldList(sheepfolds);
+ sgFeedStatistic.setSheepFoldCount(sheepCount);
+ // 计算日均饲喂量
+ sgFeedStatistic.setFeedDailySize(sgFeedStatistic.getFeedTotalSize() / sgFeedStatistic.getSheepFoldCount());
+ } else {
+ throw new RuntimeException("WARNING: 不存在该计划");
+ }
+ }
+
+}
diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
index 25e0143..0c10e17 100644
--- a/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
@@ -20,6 +20,7 @@
and formula_id = #{formulaId}
+ and formula_batch_id = #{formulaBatchId}
and zookeeper = #{zookeeper}
and deploy_date = #{deployDate}
diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedStatisticMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedStatisticMapper.xml
new file mode 100644
index 0000000..0bd9657
--- /dev/null
+++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedStatisticMapper.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ select id, formula_id, formula_batch_id, sheep_fold_count, silage_loss_rate, feed_total_size, feed_daily_size, material_list, sheep_fold_list,feed_date from sg_feed_statistic
+
+
+
+
+
+ and formula_id = #{formulaId}
+ and formula_batch_id = #{formulaBatchId}
+ and silage_loss_rate = #{silageLossRate}
+
+
+
+
+
+ where id = #{id}
+
+
+
+ insert into sg_feed_statistic
+
+ id,
+ formula_id,
+ formula_batch_id,
+ sheep_fold_count,
+ silage_loss_rate,
+ feed_total_size,
+ feed_daily_size,
+ material_list,
+ sheep_fold_list,
+ feed_date,
+
+
+ #{id},
+ #{formulaId},
+ #{formulaBatchId},
+ #{sheepFoldCount},
+ #{silageLossRate},
+ #{feedTotalSize},
+ #{feedDailySize},
+# 写入操作需要手动指定 TypeHandler 参数
+ #{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},
+ #{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},
+ #{feedDate},
+
+
+
+
+ update sg_feed_statistic
+
+ formula_id = #{formulaId},
+ formula_batch_id = #{formulaBatchId},
+ sheep_fold_count = #{sheepFoldCount},
+ silage_loss_rate = #{silageLossRate},
+ feed_total_size = #{feedTotalSize},
+ feed_daily_size = #{feedDailySize},
+ material_list = #{materialList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.SgFormulaListHandler},
+ sheep_fold_list = #{sheepFoldList, typeHandler=com.zhyc.module.feed.mapper.TypeHandler.DaSheepfoldHandler},
+ feed_date = #{feedDate},
+
+ where id = #{id}
+
+
+
+ delete from sg_feed_statistic where id = #{id}
+
+
+
+ delete from sg_feed_statistic where id in
+
+ #{id}
+
+
+
\ No newline at end of file
From a04ccfa5cf89189a41683175c5bd4fe2caa3e72d Mon Sep 17 00:00:00 2001
From: ll <1079863556@qq.com>
Date: Mon, 25 Aug 2025 16:33:58 +0800
Subject: [PATCH 08/15] =?UTF-8?q?=E9=9C=80=E6=B1=82=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../XzParityCorrectionController.java | 20 +-
.../domain/XzParityCorrection.java | 46 +-
.../mapper/XzParityCorrectionMapper.java | 4 +-
.../service/IXzParityCorrectionService.java | 3 +-
.../XzDryMatterCorrectionServiceImpl.java | 49 +-
.../impl/XzParityCorrectionServiceImpl.java | 5 +-
.../impl/XzWegihCorrectionServiceImpl.java | 48 +-
.../controller/SxSheepSaleController.java | 117 ++++
.../module/sale/domain/SxCustomerExport.java | 49 ++
.../zhyc/module/sale/domain/SxSheepSale.java | 545 ++++++++++++++++++
.../module/sale/mapper/SxSheepSaleMapper.java | 68 +++
.../sale/service/ISxSheepSaleService.java | 67 +++
.../service/impl/SxSheepSaleServiceImpl.java | 194 +++++++
.../XzDryMatterCorrectionMapper.xml | 19 +-
.../mapper/sale/SxSheepSaleMapper.xml | 207 +++++++
15 files changed, 1389 insertions(+), 52 deletions(-)
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxSheepSaleController.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxSheepSale.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxSheepSaleMapper.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxSheepSaleService.java
create mode 100644 zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxSheepSaleServiceImpl.java
create mode 100644 zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
index ee52381..8b1869f 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
@@ -25,7 +25,7 @@ import com.zhyc.common.core.page.TableDataInfo;
* 胎次校正Controller
*
* @author ruoyi
- * @date 2025-07-14
+ * @date 2025-08-24
*/
@RestController
@RequestMapping("/parityCorrection/parityCorrection")
@@ -38,20 +38,12 @@ public class XzParityCorrectionController extends BaseController
* 查询胎次校正列表
*/
@PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:list')")
-// @GetMapping("/list")
-// public TableDataInfo list(XzParityCorrection xzParityCorrection)
-// {
-// startPage();
-// List list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
-// return getDataTable(list);
-// }
- /**
- * 获取全部胎次校正(无需分页,供下拉/列表直接显示)
- */
- @GetMapping("/listAll")
- public AjaxResult listAll(XzParityCorrection xzParityCorrection){
+ @GetMapping("/list")
+ public TableDataInfo list(XzParityCorrection xzParityCorrection)
+ {
+ startPage();
List list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
- return success(list); // 直接返回数组
+ return getDataTable(list);
}
/**
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
index d1a93e6..9d803a6 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
@@ -1,8 +1,5 @@
package com.zhyc.module.dairyProducts.domain;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel;
@@ -12,11 +9,8 @@ import com.zhyc.common.core.domain.BaseEntity;
* 胎次校正对象 xz_parity_correction
*
* @author ruoyi
- * @date 2025-07-14
+ * @date 2025-08-24
*/
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
public class XzParityCorrection extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -32,4 +26,42 @@ public class XzParityCorrection extends BaseEntity
@Excel(name = "系数")
private Double coef;
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setParity(Integer parity)
+ {
+ this.parity = parity;
+ }
+
+ public Integer getParity()
+ {
+ return parity;
+ }
+
+ public void setCoef(Double coef)
+ {
+ this.coef = coef;
+ }
+
+ public Double getCoef()
+ {
+ return coef;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+ .append("id", getId())
+ .append("parity", getParity())
+ .append("coef", getCoef())
+ .toString();
+ }
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
index d2f4654..f6d1f12 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
@@ -2,15 +2,13 @@ package com.zhyc.module.dairyProducts.mapper;
import java.util.List;
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
-import org.apache.ibatis.annotations.Mapper;
/**
* 胎次校正Mapper接口
*
* @author ruoyi
- * @date 2025-07-14
+ * @date 2025-08-24
*/
-@Mapper
public interface XzParityCorrectionMapper
{
/**
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
index d5c9ce2..f7acf95 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
@@ -1,14 +1,13 @@
package com.zhyc.module.dairyProducts.service;
import java.util.List;
-
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
/**
* 胎次校正Service接口
*
* @author ruoyi
- * @date 2025-07-14
+ * @date 2025-08-24
*/
public interface IXzParityCorrectionService
{
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzDryMatterCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzDryMatterCorrectionServiceImpl.java
index 4bf9fb2..88894c8 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzDryMatterCorrectionServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzDryMatterCorrectionServiceImpl.java
@@ -44,29 +44,62 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
}
/**
- * 新增干物质校正
- *
- * @param xzDryMatterCorrection 干物质校正
- * @return 结果
+ * 新增干物质校正 - 添加默认值和重复校验
*/
@Override
public int insertXzDryMatterCorrection(XzDryMatterCorrection xzDryMatterCorrection)
{
+ // 设置干物质标准默认值为18(如果未提供)
+ if (xzDryMatterCorrection.getStandard() == null) {
+ xzDryMatterCorrection.setStandard(18.0);
+ }
+
+ // 检查同年月同厂区是否已存在
+ if (isDuplicateRecord(xzDryMatterCorrection)) {
+ throw new RuntimeException("该厂区在同一年月已存在记录,不能重复添加");
+ }
+
return xzDryMatterCorrectionMapper.insertXzDryMatterCorrection(xzDryMatterCorrection);
}
/**
- * 修改干物质校正
- *
- * @param xzDryMatterCorrection 干物质校正
- * @return 结果
+ * 修改干物质校正 - 添加重复校验
*/
@Override
public int updateXzDryMatterCorrection(XzDryMatterCorrection xzDryMatterCorrection)
{
+ // 检查同年月同厂区是否已存在(排除当前记录)
+ if (isDuplicateRecord(xzDryMatterCorrection)) {
+ throw new RuntimeException("该厂区在同一年月已存在记录,不能重复添加");
+ }
+
return xzDryMatterCorrectionMapper.updateXzDryMatterCorrection(xzDryMatterCorrection);
}
+
+ /**
+ * 检查是否存在重复记录(同年月同厂区)
+ */
+ private boolean isDuplicateRecord(XzDryMatterCorrection xzDryMatterCorrection) {
+ // 查询相同年月和厂区的记录
+ XzDryMatterCorrection query = new XzDryMatterCorrection();
+ query.setDatetime(xzDryMatterCorrection.getDatetime());
+ query.setFactory(xzDryMatterCorrection.getFactory());
+
+ List existingRecords = xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(query);
+
+ // 如果是更新操作,需要排除当前记录
+ if (xzDryMatterCorrection.getId() != null) {
+ return existingRecords.stream()
+ .anyMatch(record ->
+ !record.getId().equals(xzDryMatterCorrection.getId())
+ );
+ }
+
+ // 如果是新增操作,只要存在记录就返回true
+ return !existingRecords.isEmpty();
+ }
+
/**
* 批量删除干物质校正
*
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
index 49f5731..40f4d3f 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
@@ -1,10 +1,9 @@
package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
-
-import com.zhyc.module.dairyProducts.mapper.XzParityCorrectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import com.zhyc.module.dairyProducts.mapper.XzParityCorrectionMapper;
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
@@ -12,7 +11,7 @@ import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
* 胎次校正Service业务层处理
*
* @author ruoyi
- * @date 2025-07-14
+ * @date 2025-08-24
*/
@Service
public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzWegihCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzWegihCorrectionServiceImpl.java
index 7869c42..c27e6df 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzWegihCorrectionServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzWegihCorrectionServiceImpl.java
@@ -1,7 +1,10 @@
package com.zhyc.module.dairyProducts.service.impl;
+import java.util.Date;
import java.util.List;
+import java.util.stream.Collectors;
+import com.zhyc.common.exception.ServiceException;
import com.zhyc.module.dairyProducts.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService;
@@ -44,27 +47,60 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection);
}
+ /**
+ * 检查是否已存在相同日期和厂区的记录
+ * @param datetime 日期
+ * @param factory 厂区
+ * @param excludeId 需要排除的ID(用于更新操作时排除自身)
+ * @return 如果存在返回true,否则返回false
+ */
+ private boolean existsSameDateAndFactory(Date datetime, String factory, Long excludeId) {
+ // 创建一个查询条件对象
+ XzWegihCorrection query = new XzWegihCorrection();
+ query.setDatetime(datetime);
+ query.setFactory(factory);
+
+ // 查询符合条件的记录
+ List existingRecords = xzWegihCorrectionMapper.selectXzWegihCorrectionList(query);
+
+ // 如果有需要排除的ID(更新操作),则过滤掉自身
+ if (excludeId != null) {
+ existingRecords = existingRecords.stream()
+ .filter(record -> !record.getId().equals(excludeId))
+ .collect(Collectors.toList());
+ }
+
+ // 如果找到记录,返回true
+ return !existingRecords.isEmpty();
+ }
+
/**
* 新增称重校正
- *
- * @param xzWegihCorrection 称重校正
- * @return 结果
*/
@Override
public int insertXzWegihCorrection(XzWegihCorrection xzWegihCorrection)
{
+ // 新增前检查是否已存在相同日期和厂区的记录
+ if (existsSameDateAndFactory(xzWegihCorrection.getDatetime(), xzWegihCorrection.getFactory(), null)) {
+ // 抛出异常,提示用户已存在相同记录
+ throw new ServiceException("已存在相同日期和厂区的记录,请勿重复添加");
+ }
+
return xzWegihCorrectionMapper.insertXzWegihCorrection(xzWegihCorrection);
}
/**
* 修改称重校正
- *
- * @param xzWegihCorrection 称重校正
- * @return 结果
*/
@Override
public int updateXzWegihCorrection(XzWegihCorrection xzWegihCorrection)
{
+ // 更新前检查是否已存在相同日期和厂区的记录(排除自身)
+ if (existsSameDateAndFactory(xzWegihCorrection.getDatetime(), xzWegihCorrection.getFactory(), xzWegihCorrection.getId())) {
+ // 抛出异常,提示用户已存在相同记录
+ throw new ServiceException("已存在相同日期和厂区的记录,无法修改");
+ }
+
return xzWegihCorrectionMapper.updateXzWegihCorrection(xzWegihCorrection);
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxSheepSaleController.java b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxSheepSaleController.java
new file mode 100644
index 0000000..307ac92
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxSheepSaleController.java
@@ -0,0 +1,117 @@
+package com.zhyc.module.sale.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import com.zhyc.common.annotation.Log;
+import com.zhyc.common.core.controller.BaseController;
+import com.zhyc.common.core.domain.AjaxResult;
+import com.zhyc.common.enums.BusinessType;
+import com.zhyc.module.sale.domain.SxSheepSale;
+import com.zhyc.module.sale.service.ISxSheepSaleService;
+import com.zhyc.common.utils.poi.ExcelUtil;
+import com.zhyc.common.core.page.TableDataInfo;
+
+/**
+ * 羊只销售记录Controller
+ *
+ * @author ruoyi
+ * @date 2025-08-19
+ */
+@RestController
+@RequestMapping("/saleRecord/saleRecord")
+public class SxSheepSaleController extends BaseController {
+ @Autowired
+ private ISxSheepSaleService sxSheepSaleService;
+
+ /**
+ * 查询羊只销售记录列表
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:list')")
+ @GetMapping("/list")
+ public TableDataInfo list(SxSheepSale sxSheepSale) {
+ startPage();
+ List list = sxSheepSaleService.selectSxSheepSaleList(sxSheepSale);
+ return getDataTable(list);
+ }
+
+ /**
+ * 导出羊只销售记录列表
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:export')")
+ @Log(title = "羊只销售记录", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, SxSheepSale sxSheepSale) {
+ List list = sxSheepSaleService.selectSxSheepSaleList(sxSheepSale);
+ ExcelUtil util = new ExcelUtil(SxSheepSale.class);
+ util.exportExcel(response, list, "羊只销售记录数据");
+ }
+
+ /**
+ * 获取羊只销售记录详细信息
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:query')")
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
+ SxSheepSale sxSheepSale = sxSheepSaleService.selectSxSheepSaleById(id);
+ // 将数据库中的逗号分隔的耳号字符串转换为列表
+ if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) {
+ sxSheepSale.setBsManageTagsList(java.util.Arrays.asList(sxSheepSale.getBsManageTags().split(",")));
+ }
+ return success(sxSheepSale);
+ }
+
+ /**
+ * 新增羊只销售记录
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:add')")
+ @Log(title = "羊只销售记录", businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody SxSheepSale sxSheepSale) {
+ return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale));
+ }
+
+ /**
+ * 修改羊只销售记录
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:edit')")
+ @Log(title = "羊只销售记录", businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody SxSheepSale sxSheepSale) {
+ return toAjax(sxSheepSaleService.updateSxSheepSale(sxSheepSale));
+ }
+
+ /**
+ * 删除羊只销售记录
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:remove')")
+ @Log(title = "羊只销售记录", businessType = BusinessType.DELETE)
+ @DeleteMapping("/{ids}")
+ public AjaxResult remove(@PathVariable Long[] ids) {
+ return toAjax(sxSheepSaleService.deleteSxSheepSaleByIds(ids));
+ }
+
+ /**
+ * 【新增】根据耳号查询羊只信息
+ */
+ @PreAuthorize("@ss.hasPermi('saleRecord:saleRecord:add')" + "|| @ss.hasPermi('saleRecord:saleRecord:edit')")
+ @GetMapping("/getSheepInfo")
+ public AjaxResult getSheepInfo(@RequestParam String bsManageTags) {
+ // 调用Service方法查询信息
+ SxSheepSale sheepInfo = sxSheepSaleService.selectSheepInfoByTag(bsManageTags);
+ if (sheepInfo == null) {
+ return AjaxResult.error("未找到耳号为 [" + bsManageTags + "] 的羊只信息");
+ }
+ return AjaxResult.success(sheepInfo);
+ }
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java
new file mode 100644
index 0000000..a7d8833
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomerExport.java
@@ -0,0 +1,49 @@
+package com.zhyc.module.sale.domain;
+
+import com.zhyc.common.annotation.Excel;
+
+public class SxCustomerExport {
+ @Excel(name = "客户名称")
+ private String name;
+
+ @Excel(name = "客户电话")
+ private String phone;
+
+ @Excel(name = "客户地址")
+ private String fullAddress;
+
+ @Excel(name = "备注")
+ private String remark;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getFullAddress() {
+ return fullAddress;
+ }
+
+ public void setFullAddress(String fullAddress) {
+ this.fullAddress = fullAddress;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxSheepSale.java b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxSheepSale.java
new file mode 100644
index 0000000..aab27dc
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxSheepSale.java
@@ -0,0 +1,545 @@
+package com.zhyc.module.sale.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.zhyc.common.annotation.Excel;
+import com.zhyc.common.core.domain.BaseEntity;
+
+/**
+ * 羊只销售记录对象 sx_sheep_sale
+ *
+ * @author ruoyi
+ * @date 2025-08-19
+ */
+public class SxSheepSale extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ /** 主键ID */
+ private Long id;
+
+ /** 耳号 */
+ @Excel(name = "耳号")
+ private String bsManageTags;
+
+ /** 羊舍ID(当时销售的羊舍) */
+ @Excel(name = "羊舍ID", readConverterExp = "当=时销售的羊舍")
+ private Long sheepfoldId;
+
+ /** 品种快照 */
+ @Excel(name = "品种快照")
+ private String variety;
+
+ /** 羊只类别快照 */
+ @Excel(name = "羊只类别快照")
+ private String sheepName;
+
+ /** 性别快照 */
+ @Excel(name = "性别快照")
+ private String gender;
+
+ /** 月龄快照 */
+ @Excel(name = "月龄快照")
+ private Long monthAge;
+
+ /** 胎次快照 */
+ @Excel(name = "胎次快照")
+ private Long parity;
+
+ /** 繁育状态快照 */
+ @Excel(name = "繁育状态快照")
+ private String breed;
+
+ /** 产后天数快照 */
+ @Excel(name = "产后天数快照")
+ private Long postLambingDay;
+
+ /** 泌乳天数快照 */
+ @Excel(name = "泌乳天数快照")
+ private Long lactationDay;
+
+ /** 怀孕天数快照 */
+ @Excel(name = "怀孕天数快照")
+ private Long lambingDay;
+
+ /** 事件类型 */
+ @Excel(name = "事件类型")
+ private String eventType;
+
+ /** 销售日期 */
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ @Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd")
+ private Date saleDate;
+
+ /** 计价方式 */
+ @Excel(name = "计价方式")
+ private String pricingMethod;
+
+ /** 单价 */
+ @Excel(name = "单价")
+ private BigDecimal unitPrice;
+
+ /** 总价(自动计算) */
+ @Excel(name = "总价", readConverterExp = "自=动计算")
+ private BigDecimal totalPrice;
+
+ /** 总体重(按体重时输入) */
+ @Excel(name = "总体重", readConverterExp = "按=体重时输入")
+ private BigDecimal totalWeight;
+
+ /** 平均体重(自动) */
+ @Excel(name = "平均体重", readConverterExp = "自=动")
+ private BigDecimal avgWeight;
+
+ /** 平均单只价格(自动) */
+ @Excel(name = "平均单只价格", readConverterExp = "自=动")
+ private BigDecimal avgPricePerSheep;
+
+ /** 销售类别(dict_type = sale_type) */
+ @Excel(name = "销售类别", readConverterExp = "d=ict_type,==,s=ale_type")
+ private String saleType;
+
+ /** 疾病类型(dict_type = disea_type) */
+ @Excel(name = "疾病类型", readConverterExp = "d=ict_type,==,d=isea_type")
+ private String diseaseType;
+
+ /** 次要原因 */
+ @Excel(name = "次要原因")
+ private String secondaryReason;
+
+ /** 班组(dict_type = group) */
+ @Excel(name = "班组", readConverterExp = "d=ict_type,==,g=roup")
+ private String groupCode;
+
+ /** 客户ID(sx_customer.id) */
+ @Excel(name = "客户ID", readConverterExp = "s=x_customer.id")
+ private Long customerId;
+
+ /** 销售人员ID(sys_user.id) */
+ @Excel(name = "销售人员ID", readConverterExp = "s=ys_user.id")
+ private Long salesPersonId;
+
+ /** 检疫证号 */
+ @Excel(name = "检疫证号")
+ private String quarantineNo;
+
+ /** 审批编号 */
+ @Excel(name = "审批编号")
+ private String approvalNo;
+
+ /** 技术员ID(sys_user.id) */
+ @Excel(name = "技术员ID", readConverterExp = "s=ys_user.id")
+ private Long technicianId;
+
+ /** 处理人ID(sys_user.id) */
+ @Excel(name = "处理人ID", readConverterExp = "s=ys_user.id")
+ private Long handlerId;
+
+ /** 创建人ID(sys_user.id) */
+ @Excel(name = "创建人ID", readConverterExp = "s=ys_user.id")
+ private Long createdBy;
+
+ /** 创建时间 */
+ @JsonFormat(pattern = "yyyy-MM-dd")
+ @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+ private Date createdAt;
+
+ // 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号
+ private List bsManageTagsList;
+
+ // 【新增】非数据库字段:客户名称(从客户表查询)
+ private String customerName;
+ // 【新增】非数据库字段:客户电话
+ private String customerPhone;
+ // 【新增】非数据库字段:客户地址
+ private String customerAddress;
+ // 【新增】非数据库字段:销售人员姓名
+ private String salesPersonName;
+ // 【新增】非数据库字段:技术员姓名
+ private String technicianName;
+ // 【新增】非数据库字段:处理人姓名
+ private String handlerName;
+ // 【新增】非数据库字段:创建人姓名
+ private String createdByName;
+ // 【新增】非数据库字段:羊舍名称
+ private String sheepfoldName;
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setBsManageTags(String bsManageTags) {
+ this.bsManageTags = bsManageTags;
+ }
+
+ public String getBsManageTags() {
+ return bsManageTags;
+ }
+
+ public void setSheepfoldId(Long sheepfoldId) {
+ this.sheepfoldId = sheepfoldId;
+ }
+
+ public Long getSheepfoldId() {
+ return sheepfoldId;
+ }
+
+ public void setVariety(String variety) {
+ this.variety = variety;
+ }
+
+ public String getVariety() {
+ return variety;
+ }
+
+ public void setSheepName(String sheepName) {
+ this.sheepName = sheepName;
+ }
+
+ public String getSheepName() {
+ return sheepName;
+ }
+
+ public void setGender(String gender) {
+ this.gender = gender;
+ }
+
+ public String getGender() {
+ return gender;
+ }
+
+ public void setMonthAge(Long monthAge) {
+ this.monthAge = monthAge;
+ }
+
+ public Long getMonthAge() {
+ return monthAge;
+ }
+
+ public void setParity(Long parity) {
+ this.parity = parity;
+ }
+
+ public Long getParity() {
+ return parity;
+ }
+
+ public void setBreed(String breed) {
+ this.breed = breed;
+ }
+
+ public String getBreed() {
+ return breed;
+ }
+
+ public void setPostLambingDay(Long postLambingDay) {
+ this.postLambingDay = postLambingDay;
+ }
+
+ public Long getPostLambingDay() {
+ return postLambingDay;
+ }
+
+ public void setLactationDay(Long lactationDay) {
+ this.lactationDay = lactationDay;
+ }
+
+ public Long getLactationDay() {
+ return lactationDay;
+ }
+
+ public void setLambingDay(Long lambingDay) {
+ this.lambingDay = lambingDay;
+ }
+
+ public Long getLambingDay() {
+ return lambingDay;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setSaleDate(Date saleDate) {
+ this.saleDate = saleDate;
+ }
+
+ public Date getSaleDate() {
+ return saleDate;
+ }
+
+ public void setPricingMethod(String pricingMethod) {
+ this.pricingMethod = pricingMethod;
+ }
+
+ public String getPricingMethod() {
+ return pricingMethod;
+ }
+
+ public void setUnitPrice(BigDecimal unitPrice) {
+ this.unitPrice = unitPrice;
+ }
+
+ public BigDecimal getUnitPrice() {
+ return unitPrice;
+ }
+
+ public void setTotalPrice(BigDecimal totalPrice) {
+ this.totalPrice = totalPrice;
+ }
+
+ public BigDecimal getTotalPrice() {
+ return totalPrice;
+ }
+
+ public void setTotalWeight(BigDecimal totalWeight) {
+ this.totalWeight = totalWeight;
+ }
+
+ public BigDecimal getTotalWeight() {
+ return totalWeight;
+ }
+
+ public void setAvgWeight(BigDecimal avgWeight) {
+ this.avgWeight = avgWeight;
+ }
+
+ public BigDecimal getAvgWeight() {
+ return avgWeight;
+ }
+
+ public void setAvgPricePerSheep(BigDecimal avgPricePerSheep) {
+ this.avgPricePerSheep = avgPricePerSheep;
+ }
+
+ public BigDecimal getAvgPricePerSheep() {
+ return avgPricePerSheep;
+ }
+
+ public void setSaleType(String saleType) {
+ this.saleType = saleType;
+ }
+
+ public String getSaleType() {
+ return saleType;
+ }
+
+ public void setDiseaseType(String diseaseType) {
+ this.diseaseType = diseaseType;
+ }
+
+ public String getDiseaseType() {
+ return diseaseType;
+ }
+
+ public void setSecondaryReason(String secondaryReason) {
+ this.secondaryReason = secondaryReason;
+ }
+
+ public String getSecondaryReason() {
+ return secondaryReason;
+ }
+
+ public void setGroupCode(String groupCode) {
+ this.groupCode = groupCode;
+ }
+
+ public String getGroupCode() {
+ return groupCode;
+ }
+
+ public void setCustomerId(Long customerId) {
+ this.customerId = customerId;
+ }
+
+ public Long getCustomerId() {
+ return customerId;
+ }
+
+ public void setSalesPersonId(Long salesPersonId) {
+ this.salesPersonId = salesPersonId;
+ }
+
+ public Long getSalesPersonId() {
+ return salesPersonId;
+ }
+
+ public void setQuarantineNo(String quarantineNo) {
+ this.quarantineNo = quarantineNo;
+ }
+
+ public String getQuarantineNo() {
+ return quarantineNo;
+ }
+
+ public void setApprovalNo(String approvalNo) {
+ this.approvalNo = approvalNo;
+ }
+
+ public String getApprovalNo() {
+ return approvalNo;
+ }
+
+ public void setTechnicianId(Long technicianId) {
+ this.technicianId = technicianId;
+ }
+
+ public Long getTechnicianId() {
+ return technicianId;
+ }
+
+ public void setHandlerId(Long handlerId) {
+ this.handlerId = handlerId;
+ }
+
+ public Long getHandlerId() {
+ return handlerId;
+ }
+
+ public void setCreatedBy(Long createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Long getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ // 【新增】getter 和 setter 方法
+ public List getBsManageTagsList() {
+ return bsManageTagsList;
+ }
+
+ public void setBsManageTagsList(List bsManageTagsList) {
+ this.bsManageTagsList = bsManageTagsList;
+ }
+
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ public String getCustomerPhone() {
+ return customerPhone;
+ }
+
+ public void setCustomerPhone(String customerPhone) {
+ this.customerPhone = customerPhone;
+ }
+
+ public String getCustomerAddress() {
+ return customerAddress;
+ }
+
+ public void setCustomerAddress(String customerAddress) {
+ this.customerAddress = customerAddress;
+ }
+
+ public String getSalesPersonName() {
+ return salesPersonName;
+ }
+
+ public void setSalesPersonName(String salesPersonName) {
+ this.salesPersonName = salesPersonName;
+ }
+
+ public String getTechnicianName() {
+ return technicianName;
+ }
+
+ public void setTechnicianName(String technicianName) {
+ this.technicianName = technicianName;
+ }
+
+ public String getHandlerName() {
+ return handlerName;
+ }
+
+ public void setHandlerName(String handlerName) {
+ this.handlerName = handlerName;
+ }
+
+ public String getCreatedByName() {
+ return createdByName;
+ }
+
+ public void setCreatedByName(String createdByName) {
+ this.createdByName = createdByName;
+ }
+
+ public String getSheepfoldName() {
+ return sheepfoldName;
+ }
+
+ public void setSheepfoldName(String sheepfoldName) {
+ this.sheepfoldName = sheepfoldName;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+ .append("id", getId())
+ .append("bsManageTags", getBsManageTags())
+ .append("sheepfoldId", getSheepfoldId())
+ .append("variety", getVariety())
+ .append("sheepName", getSheepName())
+ .append("gender", getGender())
+ .append("monthAge", getMonthAge())
+ .append("parity", getParity())
+ .append("breed", getBreed())
+ .append("postLambingDay", getPostLambingDay())
+ .append("lactationDay", getLactationDay())
+ .append("lambingDay", getLambingDay())
+ .append("eventType", getEventType())
+ .append("saleDate", getSaleDate())
+ .append("pricingMethod", getPricingMethod())
+ .append("unitPrice", getUnitPrice())
+ .append("totalPrice", getTotalPrice())
+ .append("totalWeight", getTotalWeight())
+ .append("avgWeight", getAvgWeight())
+ .append("avgPricePerSheep", getAvgPricePerSheep())
+ .append("saleType", getSaleType())
+ .append("diseaseType", getDiseaseType())
+ .append("secondaryReason", getSecondaryReason())
+ .append("groupCode", getGroupCode())
+ .append("customerId", getCustomerId())
+ .append("salesPersonId", getSalesPersonId())
+ .append("quarantineNo", getQuarantineNo())
+ .append("approvalNo", getApprovalNo())
+ .append("technicianId", getTechnicianId())
+ .append("handlerId", getHandlerId())
+ .append("createdBy", getCreatedBy())
+ .append("createdAt", getCreatedAt())
+ .append("remark", getRemark())
+ .append("customerName", getCustomerName())
+ .append("customerPhone", getCustomerPhone())
+ .append("customerAddress", getCustomerAddress())
+ .append("salesPersonName", getSalesPersonName())
+ .append("technicianName", getTechnicianName())
+ .append("handlerName", getHandlerName())
+ .append("createdByName", getCreatedByName())
+ .append("sheepfoldName", getSheepfoldName())
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxSheepSaleMapper.java b/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxSheepSaleMapper.java
new file mode 100644
index 0000000..8b6788f
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/mapper/SxSheepSaleMapper.java
@@ -0,0 +1,68 @@
+package com.zhyc.module.sale.mapper;
+
+import java.util.List;
+import com.zhyc.module.sale.domain.SxSheepSale;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 羊只销售记录Mapper接口
+ *
+ * @author ruoyi
+ * @date 2025-08-19
+ */
+public interface SxSheepSaleMapper {
+ /**
+ * 查询羊只销售记录
+ *
+ * @param id 羊只销售记录主键
+ * @return 羊只销售记录
+ */
+ public SxSheepSale selectSxSheepSaleById(Long id);
+
+ /**
+ * 查询羊只销售记录列表
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 羊只销售记录集合
+ */
+ public List selectSxSheepSaleList(SxSheepSale sxSheepSale);
+
+ /**
+ * 新增羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ public int insertSxSheepSale(SxSheepSale sxSheepSale);
+
+ /**
+ * 修改羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ public int updateSxSheepSale(SxSheepSale sxSheepSale);
+
+ /**
+ * 删除羊只销售记录
+ *
+ * @param id 羊只销售记录主键
+ * @return 结果
+ */
+ public int deleteSxSheepSaleById(Long id);
+
+ /**
+ * 批量删除羊只销售记录
+ *
+ * @param ids 需要删除的数据主键集合
+ * @return 结果
+ */
+ public int deleteSxSheepSaleByIds(Long[] ids);
+
+ /**
+ * 【新增】从sheep_file视图查询羊只信息
+ * @param bsManageTags 耳号
+ * @return 羊只信息 (只包含视图中的字段)
+ */
+ public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags);
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxSheepSaleService.java b/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxSheepSaleService.java
new file mode 100644
index 0000000..bbdc73a
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/service/ISxSheepSaleService.java
@@ -0,0 +1,67 @@
+package com.zhyc.module.sale.service;
+
+import java.util.List;
+import com.zhyc.module.sale.domain.SxSheepSale;
+
+/**
+ * 羊只销售记录Service接口
+ *
+ * @author ruoyi
+ * @date 2025-08-19
+ */
+public interface ISxSheepSaleService {
+ /**
+ * 查询羊只销售记录
+ *
+ * @param id 羊只销售记录主键
+ * @return 羊只销售记录
+ */
+ public SxSheepSale selectSxSheepSaleById(Long id);
+
+ /**
+ * 查询羊只销售记录列表
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 羊只销售记录集合
+ */
+ public List selectSxSheepSaleList(SxSheepSale sxSheepSale);
+
+ /**
+ * 新增羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ public int insertSxSheepSale(SxSheepSale sxSheepSale);
+
+ /**
+ * 修改羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ public int updateSxSheepSale(SxSheepSale sxSheepSale);
+
+ /**
+ * 批量删除羊只销售记录
+ *
+ * @param ids 需要删除的羊只销售记录主键集合
+ * @return 结果
+ */
+ public int deleteSxSheepSaleByIds(Long[] ids);
+
+ /**
+ * 删除羊只销售记录信息
+ *
+ * @param id 羊只销售记录主键
+ * @return 结果
+ */
+ public int deleteSxSheepSaleById(Long id);
+
+ /**
+ * 【新增】根据耳号查询羊只信息
+ * @param bsManageTags 耳号
+ * @return 羊只信息
+ */
+ public SxSheepSale selectSheepInfoByTag(String bsManageTags);
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxSheepSaleServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxSheepSaleServiceImpl.java
new file mode 100644
index 0000000..2c47d5c
--- /dev/null
+++ b/zhyc-module/src/main/java/com/zhyc/module/sale/service/impl/SxSheepSaleServiceImpl.java
@@ -0,0 +1,194 @@
+package com.zhyc.module.sale.service.impl;
+
+import java.util.List;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.zhyc.module.sale.mapper.SxSheepSaleMapper;
+import com.zhyc.module.sale.domain.SxSheepSale;
+import com.zhyc.module.sale.service.ISxSheepSaleService;
+
+/**
+ * 羊只销售记录Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2025-08-19
+ */
+@Service
+public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
+ @Autowired
+ private SxSheepSaleMapper sxSheepSaleMapper;
+
+ /**
+ * 查询羊只销售记录
+ *
+ * @param id 羊只销售记录主键
+ * @return 羊只销售记录
+ */
+ @Override
+ public SxSheepSale selectSxSheepSaleById(Long id) {
+ return sxSheepSaleMapper.selectSxSheepSaleById(id);
+ }
+
+ /**
+ * 查询羊只销售记录列表
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 羊只销售记录
+ */
+ @Override
+ public List selectSxSheepSaleList(SxSheepSale sxSheepSale) {
+ return sxSheepSaleMapper.selectSxSheepSaleList(sxSheepSale);
+ }
+
+ /**
+ * 新增羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ @Override
+ public int insertSxSheepSale(SxSheepSale sxSheepSale) {
+ // 1. 业务验证 (例如:销售日期不能为空,淘汰销售必须填写疾病类型等)
+ validateSalesFields(sxSheepSale);
+
+ // 2. 自动计算逻辑
+ calculateSalesFields(sxSheepSale);
+
+ // 3. 设置默认事件类型
+ if (sxSheepSale.getEventType() == null) {
+ sxSheepSale.setEventType("销售");
+ }
+
+ // 4. 处理耳号列表(多个耳号用逗号分隔)
+ if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
+ sxSheepSale.setBsManageTags(String.join(",", sxSheepSale.getBsManageTagsList()));
+ }
+
+ // 5. 调用Mapper插入数据
+ return sxSheepSaleMapper.insertSxSheepSale(sxSheepSale);
+ }
+
+ /**
+ * 修改羊只销售记录
+ *
+ * @param sxSheepSale 羊只销售记录
+ * @return 结果
+ */
+ @Override
+ public int updateSxSheepSale(SxSheepSale sxSheepSale) {
+ // 1. 业务验证
+ validateSalesFields(sxSheepSale);
+
+ // 2. 自动计算逻辑
+ calculateSalesFields(sxSheepSale);
+
+ // 3. 处理耳号列表(多个耳号用逗号分隔)
+ if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
+ sxSheepSale.setBsManageTags(String.join(",", sxSheepSale.getBsManageTagsList()));
+ }
+
+ // 4. 调用Mapper更新数据
+ return sxSheepSaleMapper.updateSxSheepSale(sxSheepSale);
+ }
+
+ /**
+ * 批量删除羊只销售记录
+ *
+ * @param ids 需要删除的羊只销售记录主键
+ * @return 结果
+ */
+ @Override
+ public int deleteSxSheepSaleByIds(Long[] ids) {
+ return sxSheepSaleMapper.deleteSxSheepSaleByIds(ids);
+ }
+
+ /**
+ * 删除羊只销售记录信息
+ *
+ * @param id 羊只销售记录主键
+ * @return 结果
+ */
+ @Override
+ public int deleteSxSheepSaleById(Long id) {
+ return sxSheepSaleMapper.deleteSxSheepSaleById(id);
+ }
+
+ /**
+ * 【新增】根据耳号查询羊只信息
+ */
+ @Override
+ public SxSheepSale selectSheepInfoByTag(String bsManageTags) {
+ return sxSheepSaleMapper.selectSheepInfoByTag(bsManageTags);
+ }
+
+ /**
+ * 【新增】自动计算总价、平均体重、平均单只价格
+ */
+ private void calculateSalesFields(SxSheepSale sxSheepSale) {
+ String pricingMethod = sxSheepSale.getPricingMethod();
+ BigDecimal unitPrice = sxSheepSale.getUnitPrice();
+
+ // 获取羊只数量
+ int sheepCount = 1;
+ if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
+ sheepCount = sxSheepSale.getBsManageTagsList().size();
+ } else if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) {
+ // 如果前端没有传递列表,但有逗号分隔的字符串,也计算数量
+ sheepCount = sxSheepSale.getBsManageTags().split(",").length;
+ }
+
+ if ("按个体".equals(pricingMethod)) {
+ // 总价 = 单价 * 数量
+ if (unitPrice != null) {
+ sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount)));
+ }
+ // 平均单只价格就是单价
+ sxSheepSale.setAvgPricePerSheep(unitPrice);
+
+ } else if ("按体重".equals(pricingMethod)) {
+ BigDecimal totalWeight = sxSheepSale.getTotalWeight();
+ // 总价 = 单价 * 总重量
+ if (unitPrice != null && totalWeight != null) {
+ sxSheepSale.setTotalPrice(unitPrice.multiply(totalWeight));
+ }
+ // 平均体重 = 总重量 / 数量
+ if (totalWeight != null && sheepCount > 0) {
+ sxSheepSale.setAvgWeight(totalWeight.divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
+ }
+ // 平均单只价格 = 总价 / 数量
+ if (sxSheepSale.getTotalPrice() != null && sheepCount > 0) {
+ sxSheepSale.setAvgPricePerSheep(sxSheepSale.getTotalPrice().divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
+ }
+ }
+ // 可以添加其他计价方式的逻辑
+ }
+
+ /**
+ * 【新增】业务字段验证
+ */
+ private void validateSalesFields(SxSheepSale sxSheepSale) {
+ // 验证销售日期不能为空
+ if (sxSheepSale.getSaleDate() == null) {
+ throw new RuntimeException("销售日期不能为空!");
+ }
+
+ String saleType = sxSheepSale.getSaleType();
+ // 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型和班组不能为空
+ if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) {
+ if (sxSheepSale.getDiseaseType() == null) {
+ throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!");
+ }
+ if (sxSheepSale.getGroupCode() == null) {
+ throw new RuntimeException("淘汰销售或淘汰屠宰必须选择班组!");
+ }
+ }
+ // 如果疾病类型是"病残羊",则次要原因不能为空
+ if ("病残羊".equals(sxSheepSale.getDiseaseType())) {
+ if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) {
+ throw new RuntimeException("疾病类型为病残羊时,必须填写次要原因!");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/resources/mapper/dairyProducts/XzDryMatterCorrectionMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/XzDryMatterCorrectionMapper.xml
index eb20ee1..0fd5b29 100644
--- a/zhyc-module/src/main/resources/mapper/dairyProducts/XzDryMatterCorrectionMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/dairyProducts/XzDryMatterCorrectionMapper.xml
@@ -13,17 +13,18 @@
+
SELECT
- id,
- datetime,
- factory,
- content,
- standard,
- CASE
- WHEN standard = 0 OR standard IS NULL THEN NULL
- ELSE content / standard
- END AS coefficient
+ id,
+ datetime,
+ factory,
+ content,
+ COALESCE(standard, 18) as standard,
+ CASE
+ WHEN standard = 0 OR standard IS NULL THEN NULL
+ ELSE ROUND(content / standard, 2)
+ END AS coefficient
FROM xz_dry_matter_correction
diff --git a/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml b/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml
new file mode 100644
index 0000000..00ac0da
--- /dev/null
+++ b/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ select id, bs_manage_tags, sheepfold_id, variety, sheep_name, gender, month_age, parity, breed, post_lambing_day, lactation_day, lambing_day, event_type, sale_date, pricing_method, unit_price, total_price, total_weight, avg_weight, avg_price_per_sheep, sale_type, disease_type, secondary_reason, group_code, customer_id, sales_person_id, quarantine_no, approval_no, technician_id, handler_id, created_by, created_at, remark from sx_sheep_sale
+
+
+
+
+ select
+ bs_manage_tags,
+ variety,
+ name as sheep_name,
+ gender,
+ month_age,
+ parity,
+ breed,
+ post_lambing_day,
+ lactation_day,
+ lambing_day,
+ sheepfold_id
+ from sheep_file
+
+
+
+
+
+ where bs_manage_tags = #{bsManageTags}
+
+
+
+
+
+ and bs_manage_tags = #{bsManageTags}
+ and sheepfold_id = #{sheepfoldId}
+ and variety = #{variety}
+ and sheep_name = #{sheepName}
+ and sale_date = #{saleDate}
+ and sale_type = #{saleType}
+
+
+
+
+
+ where id = #{id}
+
+
+
+ insert into sx_sheep_sale
+
+ bs_manage_tags,
+ sheepfold_id,
+ variety,
+ sheep_name,
+ gender,
+ month_age,
+ parity,
+ breed,
+ post_lambing_day,
+ lactation_day,
+ lambing_day,
+ event_type,
+ sale_date,
+ pricing_method,
+ unit_price,
+ total_price,
+ total_weight,
+ avg_weight,
+ avg_price_per_sheep,
+ sale_type,
+ disease_type,
+ secondary_reason,
+ group_code,
+ customer_id,
+ sales_person_id,
+ quarantine_no,
+ approval_no,
+ technician_id,
+ handler_id,
+ created_by,
+ created_at,
+ remark,
+
+
+ #{bsManageTags},
+ #{sheepfoldId},
+ #{variety},
+ #{sheepName},
+ #{gender},
+ #{monthAge},
+ #{parity},
+ #{breed},
+ #{postLambingDay},
+ #{lactationDay},
+ #{lambingDay},
+ #{eventType},
+ #{saleDate},
+ #{pricingMethod},
+ #{unitPrice},
+ #{totalPrice},
+ #{totalWeight},
+ #{avgWeight},
+ #{avgPricePerSheep},
+ #{saleType},
+ #{diseaseType},
+ #{secondaryReason},
+ #{groupCode},
+ #{customerId},
+ #{salesPersonId},
+ #{quarantineNo},
+ #{approvalNo},
+ #{technicianId},
+ #{handlerId},
+ #{createdBy},
+ #{createdAt},
+ #{remark},
+
+
+
+
+ update sx_sheep_sale
+
+ bs_manage_tags = #{bsManageTags},
+ sheepfold_id = #{sheepfoldId},
+ variety = #{variety},
+ sheep_name = #{sheepName},
+ gender = #{gender},
+ month_age = #{monthAge},
+ parity = #{parity},
+ breed = #{breed},
+ post_lambing_day = #{postLambingDay},
+ lactation_day = #{lactationDay},
+ lambing_day = #{lambingDay},
+ event_type = #{eventType},
+ sale_date = #{saleDate},
+ pricing_method = #{pricingMethod},
+ unit_price = #{unitPrice},
+ total_price = #{totalPrice},
+ total_weight = #{totalWeight},
+ avg_weight = #{avgWeight},
+ avg_price_per_sheep = #{avgPricePerSheep},
+ sale_type = #{saleType},
+ disease_type = #{diseaseType},
+ secondary_reason = #{secondaryReason},
+ group_code = #{groupCode},
+ customer_id = #{customerId},
+ sales_person_id = #{salesPersonId},
+ quarantine_no = #{quarantineNo},
+ approval_no = #{approvalNo},
+ technician_id = #{technicianId},
+ handler_id = #{handlerId},
+ created_by = #{createdBy},
+ created_at = #{createdAt},
+ remark = #{remark},
+
+ where id = #{id}
+
+
+
+ delete from sx_sheep_sale where id = #{id}
+
+
+
+ delete from sx_sheep_sale where id in
+
+ #{id}
+
+
+
+
\ No newline at end of file
From 84bc8946685f7f7242a17381a4ae4453c02c40e2 Mon Sep 17 00:00:00 2001
From: ll <1079863556@qq.com>
Date: Mon, 25 Aug 2025 17:01:10 +0800
Subject: [PATCH 09/15] =?UTF-8?q?=E9=9C=80=E6=B1=82=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../XzParityCorrectionController.java | 5 ++-
.../domain/XzParityCorrection.java | 40 ++++++++++++++++++-
.../mapper/XzParityCorrectionMapper.java | 16 ++++----
.../service/IXzParityCorrectionService.java | 16 ++++----
.../impl/XzParityCorrectionServiceImpl.java | 16 ++++----
.../XzParityCorrectionMapper.xml | 16 ++++----
6 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
index 6b6ea52..db13670 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/XzParityCorrectionController.java
@@ -19,10 +19,11 @@ import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
import com.zhyc.common.utils.poi.ExcelUtil;
+import com.zhyc.common.core.page.TableDataInfo;
/**
* 胎次校正Controller
- *
+ *
* @author ruoyi
* @date 2025-08-24
*/
@@ -95,7 +96,7 @@ public class XzParityCorrectionController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:remove')")
@Log(title = "胎次校正", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
+ @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xzParityCorrectionService.deleteXzParityCorrectionByIds(ids));
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
index 9b6b3d1..9c14456 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/XzParityCorrection.java
@@ -7,7 +7,7 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 胎次校正对象 xz_parity_correction
- *
+ *
* @author ruoyi
* @date 2025-08-24
*/
@@ -26,4 +26,42 @@ public class XzParityCorrection extends BaseEntity
@Excel(name = "系数")
private Double coef;
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setParity(Integer parity)
+ {
+ this.parity = parity;
+ }
+
+ public Integer getParity()
+ {
+ return parity;
+ }
+
+ public void setCoef(Double coef)
+ {
+ this.coef = coef;
+ }
+
+ public Double getCoef()
+ {
+ return coef;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+ .append("id", getId())
+ .append("parity", getParity())
+ .append("coef", getCoef())
+ .toString();
+ }
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
index f6d1f12..3d9cf45 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/XzParityCorrectionMapper.java
@@ -5,15 +5,15 @@ import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
/**
* 胎次校正Mapper接口
- *
+ *
* @author ruoyi
* @date 2025-08-24
*/
-public interface XzParityCorrectionMapper
+public interface XzParityCorrectionMapper
{
/**
* 查询胎次校正
- *
+ *
* @param id 胎次校正主键
* @return 胎次校正
*/
@@ -21,7 +21,7 @@ public interface XzParityCorrectionMapper
/**
* 查询胎次校正列表
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 胎次校正集合
*/
@@ -29,7 +29,7 @@ public interface XzParityCorrectionMapper
/**
* 新增胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface XzParityCorrectionMapper
/**
* 修改胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface XzParityCorrectionMapper
/**
* 删除胎次校正
- *
+ *
* @param id 胎次校正主键
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface XzParityCorrectionMapper
/**
* 批量删除胎次校正
- *
+ *
* @param ids 需要删除的数据主键集合
* @return 结果
*/
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
index f7acf95..8246bdd 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/IXzParityCorrectionService.java
@@ -5,15 +5,15 @@ import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
/**
* 胎次校正Service接口
- *
+ *
* @author ruoyi
* @date 2025-08-24
*/
-public interface IXzParityCorrectionService
+public interface IXzParityCorrectionService
{
/**
* 查询胎次校正
- *
+ *
* @param id 胎次校正主键
* @return 胎次校正
*/
@@ -21,7 +21,7 @@ public interface IXzParityCorrectionService
/**
* 查询胎次校正列表
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 胎次校正集合
*/
@@ -29,7 +29,7 @@ public interface IXzParityCorrectionService
/**
* 新增胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface IXzParityCorrectionService
/**
* 修改胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface IXzParityCorrectionService
/**
* 批量删除胎次校正
- *
+ *
* @param ids 需要删除的胎次校正主键集合
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface IXzParityCorrectionService
/**
* 删除胎次校正信息
- *
+ *
* @param id 胎次校正主键
* @return 结果
*/
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
index 40f4d3f..caff850 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/XzParityCorrectionServiceImpl.java
@@ -9,19 +9,19 @@ import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
/**
* 胎次校正Service业务层处理
- *
+ *
* @author ruoyi
* @date 2025-08-24
*/
@Service
-public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
+public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
{
@Autowired
private XzParityCorrectionMapper xzParityCorrectionMapper;
/**
* 查询胎次校正
- *
+ *
* @param id 胎次校正主键
* @return 胎次校正
*/
@@ -33,7 +33,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
/**
* 查询胎次校正列表
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 胎次校正
*/
@@ -45,7 +45,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
/**
* 新增胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -57,7 +57,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
/**
* 修改胎次校正
- *
+ *
* @param xzParityCorrection 胎次校正
* @return 结果
*/
@@ -69,7 +69,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
/**
* 批量删除胎次校正
- *
+ *
* @param ids 需要删除的胎次校正主键
* @return 结果
*/
@@ -81,7 +81,7 @@ public class XzParityCorrectionServiceImpl implements IXzParityCorrectionService
/**
* 删除胎次校正信息
- *
+ *
* @param id 胎次校正主键
* @return 结果
*/
diff --git a/zhyc-module/src/main/resources/mapper/dairyProducts/XzParityCorrectionMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/XzParityCorrectionMapper.xml
index 9cf78ff..c9101f6 100644
--- a/zhyc-module/src/main/resources/mapper/dairyProducts/XzParityCorrectionMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/dairyProducts/XzParityCorrectionMapper.xml
@@ -1,9 +1,9 @@
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
+
@@ -16,12 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
+
and parity = #{parity}
and coef = #{coef}
-
+
where id = #{id}
@@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parity,
coef,
-
+
#{parity},
#{coef},
-
+
@@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- delete from xz_parity_correction where id in
+ delete from xz_parity_correction where id in
#{id}
From ec79fcd9b4f0b21b35bd6fb72a52ceb1fcbfab95 Mon Sep 17 00:00:00 2001
From: HashMap
Date: Tue, 26 Aug 2025 12:02:00 +0800
Subject: [PATCH 10/15] =?UTF-8?q?fix(module/feed):=20=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E9=85=8D=E6=96=99=E6=B8=85=E5=8D=95=E5=92=8C=E9=A5=B2=E5=96=82?=
=?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E5=AD=98=E5=9C=A8=E7=9A=84=E9=80=BB?=
=?UTF-8?q?=E8=BE=91=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
+ 修复了配料清单的分组逻辑错误:
+ 配料清单先将在原基础上再根据饲喂计划中的日期分组
+ 缓存与同步逻辑重写, 以适配新的分组逻辑
+ 修复了饲喂量统计的部分逻辑错误:
+ 解决了羊舍信息的SQL与Service层统计错误
+ 修改了缓存查询逻辑以适配新的清单缓存
---
.../feed/controller/SgFeedListController.java | 29 ++++---
.../zhyc/module/feed/domain/SgFeedList.java | 2 +
.../module/feed/mapper/SgFeedListMapper.java | 3 +
.../service/impl/SgFeedListServiceImpl.java | 83 +++++++++++++++++--
.../impl/SgFeedStatisticServiceImpl.java | 4 +-
.../mapper/feed/SgFeedListMapper.xml | 5 ++
.../mapper/feed/SgFeedPlanMapper.xml | 4 +-
7 files changed, 109 insertions(+), 21 deletions(-)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
index 895f061..db39029 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/controller/SgFeedListController.java
@@ -1,6 +1,8 @@
package com.zhyc.module.feed.controller;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@@ -63,19 +65,19 @@ public class SgFeedListController extends BaseController {
List list = sgFeedListService.selectSgFeedListList(sgFeedList);
// 用 map 中已有的数据替换 list 中的元素
List replacedList = new ArrayList<>();
- for (SgFeedList item : list) {
- String key = item.getFormulaId() + "_" + item.getFormulaBatchId();
- // 从缓存中取出完整对象
- SgFeedList itemInCache = SgFeedListServiceImpl.getSgFeedListMap().getOrDefault(key, item);
- // 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
- itemInCache.setId(item.getId());
- itemInCache.setFormulaBatchId(item.getFormulaBatchId());
- itemInCache.setFormulaId(item.getFormulaId());
- itemInCache.setZookeeper(item.getZookeeper());
- itemInCache.setDeployDate(item.getDeployDate());
- // 替换为 map 中的对象
- replacedList.add(itemInCache);
- }
+ for (SgFeedList item : list) {
+ String key = item.getFormulaId() + "_" + item.getFormulaBatchId() + "_" + item.getDeployDate();
+ // 从缓存中取出完整对象
+ SgFeedList itemInCache = SgFeedListServiceImpl.getSgFeedListMap().getOrDefault(key, item);
+ // 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
+ itemInCache.setId(item.getId());
+ itemInCache.setFormulaBatchId(item.getFormulaBatchId());
+ itemInCache.setFormulaId(item.getFormulaId());
+ itemInCache.setZookeeper(item.getZookeeper());
+ itemInCache.setDeployDate(item.getDeployDate());
+ // 替换为 map 中的对象
+ replacedList.add(itemInCache);
+ }
return getDataTable(replacedList);
}
@@ -117,6 +119,7 @@ public class SgFeedListController extends BaseController {
@Log(title = "配料清单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SgFeedList sgFeedList) {
+
return toAjax(sgFeedListService.updateSgFeedList(sgFeedList));
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedList.java b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedList.java
index 0b3c61b..41ca828 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedList.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/domain/SgFeedList.java
@@ -53,6 +53,8 @@ public class SgFeedList extends BaseEntity
private List formulaList;
+ private List planList;
+
@Override
public String toString() {
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedListMapper.java b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedListMapper.java
index 47e837c..b80e580 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedListMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/mapper/SgFeedListMapper.java
@@ -60,4 +60,7 @@ public interface SgFeedListMapper
* @return 结果
*/
int deleteSgFeedListByIds(Long[] ids);
+
+ // 清空所有
+ int deleteAll();
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
index 225d851..894ff47 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedListServiceImpl.java
@@ -1,8 +1,6 @@
package com.zhyc.module.feed.service.impl;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import com.zhyc.module.feed.domain.SgFeedPlan;
import com.zhyc.module.feed.domain.SgFormulaManagement;
@@ -32,6 +30,12 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
this.sgFeedListMapper = sgFeedListMapper;
this.sgFormulaManagementService = sgFormulaManagementService;
this.sgFeedPlanService = sgFeedPlanService;
+ // 构造时将数据库初始数据写入缓存
+ List feedListsFromDataBase = this.selectSgFeedListList(new SgFeedList());
+ for (SgFeedList sgFeedListItem : feedListsFromDataBase) {
+ String key = sgFeedListItem.getFormulaId() + "_" + sgFeedListItem.getFormulaBatchId() + "_" + sgFeedListItem.getDeployDate();
+ sgFeedListMap.put(key, sgFeedListItem);
+ }
}
/**
@@ -100,7 +104,7 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
return sgFeedListMapper.deleteSgFeedListById(id);
}
- public void SyncFeedList() {
+ public void SyncFeedList_old() {
// 清空旧缓存
sgFeedListMap.clear();
// 获取配方管理和现有配料清单内容
@@ -153,6 +157,74 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
}
}
+ public void SyncFeedList() {
+ HashMap cacheTemp = new HashMap<>(sgFeedListMap);
+ // 清空旧缓存
+ sgFeedListMap.clear();
+ List sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(new SgFeedPlan());
+ List> planGroups = new ArrayList<>();
+ List currentFeedPlan = new ArrayList<>();
+ if (!sgFeedPlans.isEmpty()) {
+ String currentFormulaId = sgFeedPlans.get(0).getFormulaId();
+ String currentBatchId = sgFeedPlans.get(0).getBatchId();
+ Date currentDate = sgFeedPlans.get(0).getPlanDate();
+ // 对饲喂计划进行分组
+ for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
+ if (sgFeedPlan.getBatchId() != null && !sgFeedPlan.getBatchId().equals("0")) {
+ if (sgFeedPlan.getFormulaId().equals(currentFormulaId) && sgFeedPlan.getBatchId().equals(currentBatchId) && sgFeedPlan.getPlanDate().equals(currentDate)) {
+ currentFeedPlan.add(sgFeedPlan);
+ } else {
+ currentDate = sgFeedPlan.getPlanDate();
+ currentBatchId = sgFeedPlan.getBatchId();
+ currentFormulaId = sgFeedPlan.getFormulaId();
+ planGroups.add(currentFeedPlan);
+ currentFeedPlan = new ArrayList<>();
+ // 立即插入否则会丢失该元素
+ currentFeedPlan.add(sgFeedPlan);
+ }
+ }
+ }
+ // 插入最后一个列表 - 否则该列表会丢失
+ planGroups.add(currentFeedPlan);
+ // 注册数据 - 每一个List为一个清单
+ for (List sgFeedPlanList : planGroups) {
+ SgFeedList sgFeedList = new SgFeedList();
+ // 计算饲喂总和
+ SgFeedPlan rootPlan = computePlanTotal(sgFeedPlanList);
+ sgFeedList.setRootPlan(rootPlan);
+ sgFeedList.setPlanList(sgFeedPlanList);
+ // 写入信息
+ sgFeedList.setFormulaId(sgFeedPlanList.get(0).getFormulaId());
+ sgFeedList.setFormulaBatchId(sgFeedPlanList.get(0).getBatchId());
+ sgFeedList.setDeployDate(sgFeedPlanList.get(0).getPlanDate());
+ // 写入配方管理信息
+ SgFormulaManagement formulaManagementQuery = new SgFormulaManagement();
+ formulaManagementQuery.setFormulaId(sgFeedList.getFormulaId());
+ formulaManagementQuery.setBatchId(sgFeedList.getFormulaBatchId());
+ List formulaManagements = sgFormulaManagementService.selectSgFormulaManagementList(formulaManagementQuery);
+ if (!formulaManagements.isEmpty()) {
+ sgFeedList.setRootFormula(formulaManagements.get(0));
+ sgFeedList.setFormulaList(formulaManagements.get(0).getSgFormulaList());
+ }
+ String cacheKey = sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId() + "_" + sgFeedList.getDeployDate();
+ // 从就缓存中查找,如果存在则更新可修改的值
+ if (cacheTemp.containsKey(cacheKey)) {
+ SgFeedList cacheItem = cacheTemp.get(cacheKey);
+ sgFeedList.setZookeeper(cacheItem.getZookeeper());
+ }
+ sgFeedListMap.put(cacheKey, sgFeedList);
+ }
+
+ List toDataBase = new ArrayList<>(sgFeedListMap.values());
+ // 清空再写入
+ this.sgFeedListMapper.deleteAll();
+ // 处理结果写入数据库
+ for (SgFeedList recordItem : toDataBase) {
+ this.insertSgFeedList(recordItem);
+ }
+ }
+ }
+
/**
* 计算某个配方某个批次的总和值
*
@@ -176,7 +248,8 @@ public class SgFeedListServiceImpl implements ISgFeedListService {
planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
}
-
+ rootPlan.setFormulaId(sgFeedPlans.get(0).getFormulaId());
+ rootPlan.setBatchId(sgFeedPlans.get(0).getBatchId());
rootPlan.setSheepCount(sheepCountTotal);
rootPlan.setPlanDailySize(sheepDailySize);
rootPlan.setPlanMorningSize(planFeedMorningSize);
diff --git a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
index b1766bd..b82d0b4 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/feed/service/impl/SgFeedStatisticServiceImpl.java
@@ -119,7 +119,7 @@ public class SgFeedStatisticServiceImpl implements ISgFeedStatisticService {
sgFeedListService.SyncFeedList();
// 从缓存获取完整配方清单
- String cacheKey = sgFeedStatistic.getFormulaId() + "_" + sgFeedStatistic.getFormulaBatchId();
+ String cacheKey = sgFeedStatistic.getFormulaId() + "_" + sgFeedStatistic.getFormulaBatchId() + "_" + sgFeedStatistic.getFeedDate();
SgFeedList sgFeedList = SgFeedListServiceImpl.getSgFeedListMap().get(cacheKey);
if (sgFeedList != null && sgFeedList.getFormulaList() != null) {
@@ -148,7 +148,7 @@ public class SgFeedStatisticServiceImpl implements ISgFeedStatisticService {
SgFeedPlan sgFeedPlanQuery = new SgFeedPlan();
sgFeedPlanQuery.setFormulaId(sgFeedStatistic.getFormulaId());
sgFeedPlanQuery.setBatchId(sgFeedStatistic.getFormulaBatchId());
-
+ sgFeedPlanQuery.setPlanDate(sgFeedStatistic.getFeedDate());
List sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(sgFeedPlanQuery);
if (!sgFeedPlans.isEmpty()) {
diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
index 0c10e17..86932be 100644
--- a/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedListMapper.xml
@@ -24,6 +24,7 @@
and zookeeper = #{zookeeper}
and deploy_date = #{deployDate}
+ ORDER BY deploy_date ASC, formula_id ASC, formula_batch_id ASC
@@ -68,4 +69,8 @@
#{id}
+
+
+ DELETE FROM sg_feed_list;
+
\ No newline at end of file
diff --git a/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml b/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml
index b67f3df..cf23ac3 100644
--- a/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/feed/SgFeedPlanMapper.xml
@@ -37,9 +37,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and formula_id = #{formulaId}
+ and batch_id = #{batchId}
and sheep_house_id = #{sheepHouseId}
+ and plan_date = #{planDate}
- ORDER BY formula_id ASC, plan_date ASC
+ ORDER BY plan_date ASC, formula_id ASC , batch_id ASC
From 253249076f9cb5d21c5deb1cd5c988a29eaf9948 Mon Sep 17 00:00:00 2001
From: zyh <2066096076@qq.com>
Date: Tue, 26 Aug 2025 17:03:45 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E6=B5=8B=E8=AF=951.0=E4=B8=AD=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../zhyc/module/produce/bodyManage/domain/ScBreastRating.java | 2 +-
.../module/produce/manage_sheep/domain/ScChangeComment.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java
index 872bf26..4eda878 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBreastRating.java
@@ -31,7 +31,7 @@ public class ScBreastRating extends BaseEntity {
*/
private String sheepId;
- @Excel(name = "羊只id")
+ @Excel(name = "管理耳号")
private String manageTags;
/**
diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java
index 8e1b0cb..5db6214 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeComment.java
@@ -27,7 +27,7 @@ public class ScChangeComment extends BaseEntity {
* 羊只id
*/
private String sheepId;
-
+ @Excel(name = "管理耳号")
private String manageTags;
/** 羊舍 */
From fd7e83dc776f3e350aeb2998d21d457d6a877002 Mon Sep 17 00:00:00 2001
From: piaobo <1913856125@qq.com>
Date: Tue, 26 Aug 2025 17:04:33 +0800
Subject: [PATCH 12/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B9=E6=8D=AE?=
=?UTF-8?q?=E8=80=B3=E5=8F=B7=E8=BF=9B=E8=A1=8C=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/resources/mapper/biosafety/DewormMapper.xml | 1 +
.../main/resources/mapper/biosafety/HealthMapper.xml | 9 ++++++++-
.../main/resources/mapper/biosafety/ImmunityMapper.xml | 7 ++++++-
.../resources/mapper/biosafety/TreatmentMapper.xml | 10 +++++++++-
4 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml
index 1371396..9efa115 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml
@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and sheep_id = #{sheepId}
+ and bs.manage_tags like concat('%',#{sheepNo},'%')
and datetime between #{params.beginDatetime} and #{params.endDatetime}
and technical = #{technical}
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml
index 3de1d50..09684ab 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml
@@ -34,9 +34,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
+ select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
+ s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
+ bs.manage_tags sheep_no
+ from sw_health s
+ left join bas_sheep bs on s.sheep_id = bs.id
+
and datetime = #{datetime}
+ and bs.manage_tags like concat('%',#{sheepNo},'%')
+ and datetime between #{params.beginDatetime} and #{params.endDatetime}
and technical = #{technical}
ORDER BY datetime DESC
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml
index ad52e4e..9265410 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml
@@ -32,10 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
+ select s.id, datetime, sheep_id, usage_id, variety, sheep_type, s.gender, month_age, s.parity, breed, technical,
+ s.comment, s.update_by, s.update_time, s.create_by, s.create_time,
+ bs.manage_tags sheep_no
+ from sw_immunity s
+ left join bas_sheep bs on s.sheep_id = bs.id
and sheep_id = #{sheepId}
and sheep_type = #{sheepType}
+ and bs.manage_tags like concat('%',#{sheepNo},'%')
and datetime between #{params.beginDatetime} and #{params.endDatetime}
and technical = #{technical}
diff --git a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
index 5e07a30..2ee56a2 100644
--- a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml
@@ -44,9 +44,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
+ select t.id, diag_id, sheep_id, variety, sheep_type, month_age, t.gender, t.parity, breed, lact_day, gest_day, datetime, disease_id, disease_pid, veterinary, usage_id,status, t.comment, t.update_by, t.update_time, t.create_by, t.create_time,
+ bs.manage_tags,
+ sd.name disease_name,
+ sd2.name disease_pname
+ from sw_treatment t
+ left join bas_sheep bs on t.sheep_id = bs.id
+ left join sw_disease sd on t.disease_id = sd.id
+ left join sw_disease sd2 on t.disease_pid = sd2.id
and sheep_id = #{sheepId}
+ and bs.manage_tags like concat('%',#{sheepNo},'%')
and datetime between #{params.beginDatetime} and #{params.endDatetime}
and disease_id = #{diseaseId}
and status = #{status}
From a7fd5f303faa1eb8b24aada9e236a81b468529d7 Mon Sep 17 00:00:00 2001
From: HashMap
Date: Tue, 26 Aug 2025 17:08:12 +0800
Subject: [PATCH 13/15] =?UTF-8?q?fix(Mapper/stock):=20=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
+ 修复了入库记录无法根据日期查询的问题
+ 通过改进SQL解决
+ 修复了物资管理无法根据日期查询的问题
+ 通过改进SQL解决
---
.../com/zhyc/module/stock/controller/WzStockInController.java | 1 +
.../resources/mapper/stock/WzMaterialsManagementMapper.xml | 3 ++-
.../src/main/resources/mapper/stock/WzStockInMapper.xml | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/stock/controller/WzStockInController.java b/zhyc-module/src/main/java/com/zhyc/module/stock/controller/WzStockInController.java
index 6705202..4eef0ae 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/stock/controller/WzStockInController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/stock/controller/WzStockInController.java
@@ -47,6 +47,7 @@ public class WzStockInController extends BaseController
{
startPage();
List list = wzStockInService.selectWzStockInList(wzStockIn);
+ logger.debug(wzStockIn.toString());
return getDataTable(list);
}
diff --git a/zhyc-module/src/main/resources/mapper/stock/WzMaterialsManagementMapper.xml b/zhyc-module/src/main/resources/mapper/stock/WzMaterialsManagementMapper.xml
index d2347c4..7caa4fd 100644
--- a/zhyc-module/src/main/resources/mapper/stock/WzMaterialsManagementMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/stock/WzMaterialsManagementMapper.xml
@@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and material_name like concat('%', #{materialName}, '%')
- and production_date between #{params.beginProductionDate} and #{params.endProductionDate}
+ and production_date between #{params.beginProductionDate} and #{params.endProductionDate}
+ and production_date = #{productionDate}
diff --git a/zhyc-module/src/main/resources/mapper/stock/WzStockInMapper.xml b/zhyc-module/src/main/resources/mapper/stock/WzStockInMapper.xml
index 55c5c1e..d472047 100644
--- a/zhyc-module/src/main/resources/mapper/stock/WzStockInMapper.xml
+++ b/zhyc-module/src/main/resources/mapper/stock/WzStockInMapper.xml
@@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and business_type = #{businessType}
and repository_name like concat('%', #{repositoryName}, '%')
and material_name like concat('%', #{materialName}, '%')
+ and doc_date = #{docDate}
From 29efc433927e35e104778587e22428e164059465 Mon Sep 17 00:00:00 2001
From: ll <1079863556@qq.com>
Date: Thu, 28 Aug 2025 11:12:31 +0800
Subject: [PATCH 14/15] =?UTF-8?q?=E7=8F=AD=E6=AC=A1=E5=A5=B6=E9=87=8F?=
=?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/zhyc/common/annotation/Excel.java | 5 +
.../com/zhyc/common/utils/poi/ExcelUtil.java | 116 +++++++++++-------
.../NpMilkProdClassesController.java | 6 +-
.../domain/NpMilkProdClasses.java | 6 +-
4 files changed, 85 insertions(+), 48 deletions(-)
diff --git a/zhyc-common/src/main/java/com/zhyc/common/annotation/Excel.java b/zhyc-common/src/main/java/com/zhyc/common/annotation/Excel.java
index e9d66a7..47402dc 100644
--- a/zhyc-common/src/main/java/com/zhyc/common/annotation/Excel.java
+++ b/zhyc-common/src/main/java/com/zhyc/common/annotation/Excel.java
@@ -33,6 +33,11 @@ public @interface Excel
*/
public String dateFormat() default "";
+ /**
+ * 数字格式, 如: 0.00
+ */
+ public String numFormat() default ""; // 新增数字格式属性
+
/**
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
*/
diff --git a/zhyc-common/src/main/java/com/zhyc/common/utils/poi/ExcelUtil.java b/zhyc-common/src/main/java/com/zhyc/common/utils/poi/ExcelUtil.java
index d595cee..35269b0 100644
--- a/zhyc-common/src/main/java/com/zhyc/common/utils/poi/ExcelUtil.java
+++ b/zhyc-common/src/main/java/com/zhyc/common/utils/poi/ExcelUtil.java
@@ -88,7 +88,7 @@ import com.zhyc.common.utils.reflect.ReflectUtils;
/**
* Excel相关处理
- *
+ *
* @author ruoyi
*/
public class ExcelUtil
@@ -307,7 +307,7 @@ public class ExcelUtil
/**
* 对excel表单默认第一个索引名转换成list
- *
+ *
* @param is 输入流
* @return 转换后集合
*/
@@ -318,7 +318,7 @@ public class ExcelUtil
/**
* 对excel表单默认第一个索引名转换成list
- *
+ *
* @param is 输入流
* @param titleNum 标题占用行数
* @return 转换后集合
@@ -344,7 +344,7 @@ public class ExcelUtil
/**
* 对excel表单指定表格索引名转换成list
- *
+ *
* @param sheetName 表格索引名
* @param titleNum 标题占用行数
* @param is 输入流
@@ -527,7 +527,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
@@ -539,7 +539,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @param title 标题
@@ -553,7 +553,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param response 返回数据
* @param list 导出数据集合
* @param sheetName 工作表的名称
@@ -566,7 +566,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param response 返回数据
* @param list 导出数据集合
* @param sheetName 工作表的名称
@@ -583,7 +583,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param sheetName 工作表的名称
* @return 结果
*/
@@ -594,7 +594,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
@@ -607,7 +607,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param sheetName 工作表的名称
* @return 结果
*/
@@ -618,7 +618,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
@@ -633,7 +633,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @return 结果
*/
public void exportExcel(HttpServletResponse response)
@@ -655,7 +655,7 @@ public class ExcelUtil
/**
* 对list数据源将其里面的数据导入到excel表单
- *
+ *
* @return 结果
*/
public AjaxResult exportExcel()
@@ -723,7 +723,7 @@ public class ExcelUtil
/**
* 填充excel数据
- *
+ *
* @param index 序号
* @param row 单元格行
*/
@@ -821,7 +821,7 @@ public class ExcelUtil
/**
* 创建表格样式
- *
+ *
* @param wb 工作薄对象
* @return 样式列表
*/
@@ -876,7 +876,7 @@ public class ExcelUtil
/**
* 根据Excel注解创建表格头样式
- *
+ *
* @param wb 工作薄对象
* @return 自定义样式列表
*/
@@ -912,7 +912,7 @@ public class ExcelUtil
/**
* 根据Excel注解创建表格列样式
- *
+ *
* @param wb 工作薄对象
* @return 自定义样式列表
*/
@@ -944,7 +944,7 @@ public class ExcelUtil
/**
* 根据Excel注解创建表格列样式
- *
+ *
* @param styles 自定义样式列表
* @param field 属性列信息
* @param excel 注解信息
@@ -1007,7 +1007,7 @@ public class ExcelUtil
/**
* 设置单元格信息
- *
+ *
* @param value 单元格值
* @param attr 注解相关
* @param cell 单元格信息
@@ -1142,7 +1142,6 @@ public class ExcelUtil
sheet.addMergedRegion(new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column));
}
}
- cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
// 用于读取对象中的属性
Object value = getTargetValue(vo, field, attr);
@@ -1150,14 +1149,33 @@ public class ExcelUtil
String readConverterExp = attr.readConverterExp();
String separator = attr.separator();
String dictType = attr.dictType();
- if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
+ String numFormat = attr.numFormat(); // 获取数字格式
+
+ // 创建单元格样式
+ CellStyle cellStyle = wb.createCellStyle();
+ cellStyle.cloneStyleFrom(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}",
+ attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
+
+ // 处理日期格式
+ if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value) && value instanceof Date)
{
- cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
- cell.setCellValue(parseDateToStr(dateFormat, value));
+ DataFormat format = wb.createDataFormat();
+ cellStyle.setDataFormat(format.getFormat(dateFormat));
+ cell.setCellValue((Date) value);
+ cell.setCellStyle(cellStyle);
+ }
+ // 处理数字格式
+ else if (StringUtils.isNotEmpty(numFormat) && StringUtils.isNotNull(value) && value instanceof Number)
+ {
+ DataFormat format = wb.createDataFormat();
+ cellStyle.setDataFormat(format.getFormat(numFormat));
+ cell.setCellValue(((Number) value).doubleValue());
+ cell.setCellStyle(cellStyle);
}
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
{
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
+ cell.setCellStyle(cellStyle);
}
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
{
@@ -1167,20 +1185,32 @@ public class ExcelUtil
sysDictMap.put(dictType + value, lable);
}
cell.setCellValue(sysDictMap.get(dictType + value));
+ cell.setCellStyle(cellStyle);
}
else if (value instanceof BigDecimal && -1 != attr.scale())
{
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue());
+ cell.setCellStyle(cellStyle);
}
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
{
cell.setCellValue(dataFormatHandlerAdapter(value, attr, cell));
+ cell.setCellStyle(cellStyle);
}
else
{
// 设置列类型
setCellVo(value, attr, cell);
+ // 对于日期类型,确保应用日期格式
+ if (value instanceof Date && StringUtils.isNotEmpty(dateFormat)) {
+ DataFormat format = wb.createDataFormat();
+ CellStyle dateStyle = wb.createCellStyle();
+ dateStyle.cloneStyleFrom(cell.getCellStyle());
+ dateStyle.setDataFormat(format.getFormat(dateFormat));
+ cell.setCellStyle(dateStyle);
+ }
}
+
addStatisticsData(column, Convert.toStr(value), attr);
}
}
@@ -1193,7 +1223,7 @@ public class ExcelUtil
/**
* 设置 POI XSSFSheet 单元格提示或选择框
- *
+ *
* @param sheet 表单
* @param textlist 下拉框显示的内容
* @param promptContent 提示内容
@@ -1203,7 +1233,7 @@ public class ExcelUtil
* @param endCol 结束列
*/
public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow,
- int firstCol, int endCol)
+ int firstCol, int endCol)
{
DataValidationHelper helper = sheet.getDataValidationHelper();
DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1");
@@ -1230,7 +1260,7 @@ public class ExcelUtil
/**
* 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框).
- *
+ *
* @param sheet 要设置的sheet.
* @param textlist 下拉框显示的内容
* @param promptContent 提示内容
@@ -1254,7 +1284,7 @@ public class ExcelUtil
DataValidationHelper helper = sheet.getDataValidationHelper();
// 加载下拉列表内容
DataValidationConstraint constraint = helper.createFormulaListConstraint(hideSheetName + "_data");
- // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
+ // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
DataValidation dataValidation = helper.createValidation(constraint, regions);
@@ -1282,7 +1312,7 @@ public class ExcelUtil
/**
* 解析导出值 0=男,1=女,2=未知
- *
+ *
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
@@ -1319,7 +1349,7 @@ public class ExcelUtil
/**
* 反向解析值 男=0,女=1,未知=2
- *
+ *
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
@@ -1356,7 +1386,7 @@ public class ExcelUtil
/**
* 解析字典值
- *
+ *
* @param dictValue 字典值
* @param dictType 字典类型
* @param separator 分隔符
@@ -1369,7 +1399,7 @@ public class ExcelUtil
/**
* 反向解析值字典值
- *
+ *
* @param dictLabel 字典标签
* @param dictType 字典类型
* @param separator 分隔符
@@ -1382,7 +1412,7 @@ public class ExcelUtil
/**
* 数据处理器
- *
+ *
* @param value 数据值
* @param excel 数据注解
* @return
@@ -1458,7 +1488,7 @@ public class ExcelUtil
/**
* 获取下载路径
- *
+ *
* @param filename 文件名称
*/
public String getAbsoluteFile(String filename)
@@ -1474,7 +1504,7 @@ public class ExcelUtil
/**
* 获取bean中的属性值
- *
+ *
* @param vo 实体对象
* @param field 字段
* @param excel 注解
@@ -1506,7 +1536,7 @@ public class ExcelUtil
/**
* 以类的属性的get方法方法形式获取值
- *
+ *
* @param o
* @param name
* @return value
@@ -1649,7 +1679,7 @@ public class ExcelUtil
/**
* 创建工作表
- *
+ *
* @param sheetNo sheet数量
* @param index 序号
*/
@@ -1666,7 +1696,7 @@ public class ExcelUtil
/**
* 获取单元格值
- *
+ *
* @param row 获取的行
* @param column 获取单元格列号
* @return 单元格值
@@ -1726,7 +1756,7 @@ public class ExcelUtil
/**
* 判断是否是空行
- *
+ *
* @param row 判断的行
* @return
*/
@@ -1754,7 +1784,7 @@ public class ExcelUtil
* @param workbook 工作簿对象
* @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
*/
- public static Map> getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
+ public static Map > getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
{
Map> sheetIndexPicMap = new HashMap<>();
List pictures = workbook.getAllPictures();
@@ -1807,7 +1837,7 @@ public class ExcelUtil
/**
* 格式化不同类型的日期对象
- *
+ *
* @param dateFormat 日期格式
* @param val 被格式化的日期对象
* @return 格式化后的日期字符
@@ -1873,7 +1903,7 @@ public class ExcelUtil
/**
* 获取对象的子列表方法
- *
+ *
* @param name 名称
* @param pojoClass 类对象
* @return 子列表方法
@@ -1894,4 +1924,4 @@ public class ExcelUtil
}
return method;
}
-}
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkProdClassesController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkProdClassesController.java
index 32e7db8..da0cde1 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkProdClassesController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkProdClassesController.java
@@ -58,10 +58,12 @@ public class NpMilkProdClassesController extends BaseController {
public void export(HttpServletResponse response,
@RequestParam(required = false) Date datetimeStart,
@RequestParam(required = false) Date datetimeEnd,
- @RequestParam(required = false) String manageEarNos,
+ @RequestParam(required = false) String manageEarNo,
@RequestParam(required = false) String factory,
@RequestParam(required = false) Integer classes) {
- List list = npMilkProdClassesService.selectNpMilkProdClassesList(datetimeStart, datetimeEnd, manageEarNos, factory, classes);
+ List list = npMilkProdClassesService.selectNpMilkProdClassesList(
+ datetimeStart, datetimeEnd, manageEarNo, factory, classes);
+
ExcelUtil util = new ExcelUtil<>(NpMilkProdClasses.class);
util.exportExcel(response, list, "班次产奶数据");
}
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpMilkProdClasses.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpMilkProdClasses.java
index 19e2ce9..43d388d 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpMilkProdClasses.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpMilkProdClasses.java
@@ -15,7 +15,7 @@ public class NpMilkProdClasses implements Serializable {
private Date updateTime; // 更新时间
@JsonFormat(pattern = "yyyy-MM-dd")
- @Excel(name = "日期")
+ @Excel(name = "日期", dateFormat = "yyyy-MM-dd") // 添加日期格式
private Date datetime;
@Excel(name = "管理耳号")
@@ -33,10 +33,10 @@ public class NpMilkProdClasses implements Serializable {
@Excel(name = "班次")
private Integer classes;
- @Excel(name = "班次产奶量")
+ @Excel(name = "班次产奶量", numFormat = "0.00")
private Double milk;
- @Excel(name = "班次校正奶量")
+ @Excel(name = "班次校正奶量", numFormat = "0.00")
private Double correctedMilk;
private String sheepId;
From c8f7b6baffc1255f67abd667b6506451f22cb6fe Mon Sep 17 00:00:00 2001
From: ll <1079863556@qq.com>
Date: Fri, 29 Aug 2025 17:24:43 +0800
Subject: [PATCH 15/15] =?UTF-8?q?=E9=85=B8=E5=A5=B6=E6=A3=80=E9=AA=8C?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E9=B2=9C=E5=A5=B6=E6=A3=80=E9=AA=8C?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=E3=80=81=E7=94=9F=E4=B9=B3=E6=A3=80=E9=AA=8C?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=E9=A1=B5=E9=9D=A2=E5=AF=BC=E5=87=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=A5=B6=E4=BA=A7=E9=87=8F=E5=88=86=E6=9E=90?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8A=A5=E9=94=99=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../NpSheepMilkAnalysisController.java | 11 +--
.../domain/NpSheepMilkAnalysis.java | 75 +++++++++++++++++--
.../mapper/NpSheepMilkAnalysisMapper.java | 9 ++-
.../service/INpSheepMilkAnalysisService.java | 7 +-
.../impl/NpSheepMilkAnalysisServiceImpl.java | 18 +++--
.../NpSheepMilkAnalysisMapper.xml | 30 ++++++--
6 files changed, 124 insertions(+), 26 deletions(-)
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java
index 3e4f07a..bce4136 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpSheepMilkAnalysisController.java
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
+ * 奶产量分析控制器
* 只保留:分页列表(只读) + 单条查询 + 导出
*/
@RestController
@@ -29,13 +30,13 @@ public class NpSheepMilkAnalysisController extends BaseController {
*/
@GetMapping("/list")
public TableDataInfo list(NpSheepMilkAnalysis analysis) {
- startPage(); // 使用 PageHelper 分页(注意 service 中第一个 DB 调用是 distinct sheep id)
+ startPage(); // 使用PageHelper分页(注意service中第一个DB调用是distinct sheep id)
List list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
return getDataTable(list);
}
/**
- * 获取单个分析记录详细信息(按 sheepId)
+ * 获取单个分析记录详细信息(按sheepId)
*/
@GetMapping(value = "/{sheepId}")
public AjaxResult getInfo(@PathVariable("sheepId") String sheepId) {
@@ -44,13 +45,13 @@ public class NpSheepMilkAnalysisController extends BaseController {
/**
* 导出奶产量分析记录(Excel)
- * 支持 manageEarTag 与 screenDays 两个查询条件
+ * 支持manageEarTag与screenDays两个查询条件
*/
@Log(title = "奶产量分析 导出", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(NpSheepMilkAnalysis analysis) {
- List list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisList(analysis);
+ List list = npSheepMilkAnalysisService.selectNpSheepMilkAnalysisForExport(analysis);
ExcelUtil util = new ExcelUtil<>(NpSheepMilkAnalysis.class);
return util.exportExcel(list, "羊奶产量分析数据");
}
-}
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java
index 0573a0d..84cedc0 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/domain/NpSheepMilkAnalysis.java
@@ -1,78 +1,141 @@
package com.zhyc.module.dairyProducts.domain;
+import com.zhyc.common.annotation.Excel;
import java.util.Date;
public class NpSheepMilkAnalysis {
// 唯一键(可用于前端 row-key)
+ @Excel(name = "羊只ID")
private String sheepId;
// 耳号(从 sheep_file.bs_manage_tags)
+ @Excel(name = "耳号")
private String manageEarTag;
+ @Excel(name = "品种")
private String variety;
// 最高校正胎次的挤奶开始时间 & 干奶时间
+ @Excel(name = "挤奶开始时间", dateFormat = "yyyy-MM-dd")
private Date milkingStartTime;
+
+ @Excel(name = "干奶时间", dateFormat = "yyyy-MM-dd")
private Date dryEndTime;
// 挤奶天数(该胎次)
+ @Excel(name = "挤奶天数")
private Integer milkingDays;
// 前端传入的筛选天数(screenDays)
+ @Excel(name = "筛选天数")
private Integer screenDays;
// 分析天数(若你有不同命名,可忽略)
private Integer analysisDays;
// 校正后最大胎次(即校正奶量之和最大的胎次)
+ @Excel(name = "校正后最大胎次")
private Integer maxParity;
// 最高校正胎次区间内的系统奶量与校正奶量(按筛选窗口)
+ @Excel(name = "系统奶量合计")
private Double sumSystemMilk;
+
+ @Excel(name = "校正奶量合计")
private Double sumCorrectedMilk;
- // 校正日平均奶量(按 min(挤奶天数, 筛选天数))
+ // 校正日平均奶量(按min(挤奶天数,筛选天数))
+ @Excel(name = "校正日平均奶量")
private Double avgCorrectedDaily;
// 各胎次总奶量(校正)
+ @Excel(name = "胎次1总奶量")
private Double sumParity1Milk;
+
+ @Excel(name = "胎次2总奶量")
private Double sumParity2Milk;
+
+ @Excel(name = "胎次3总奶量")
private Double sumParity3Milk;
+
+ @Excel(name = "胎次4总奶量")
private Double sumParity4Milk;
// 各胎次日平均(按规则)
+ @Excel(name = "胎次1日平均")
private Double avgParity1Daily;
+
+ @Excel(name = "胎次2日平均")
private Double avgParity2Daily;
+
+ @Excel(name = "胎次3日平均")
private Double avgParity3Daily;
+
+ @Excel(name = "胎次4日平均")
private Double avgParity4Daily;
// 泌乳天数(sheep_file.lactation_day)
+ @Excel(name = "泌乳天数")
private Integer lactationDays;
- // 过去 7 / 14 / 30 日平均(系统奶量)
+ // 过去7/14/30日平均(系统奶量)
+ @Excel(name = "过去7日均奶量")
private Double avgLast7Milk;
- private Double avgLast7Corrected; // = avgLast7Milk * weightCoefficient (默认 1.0)
+
+ @Excel(name = "校正过去7日均")
+ private Double avgLast7Corrected;
+
+ @Excel(name = "过去14日均奶量")
private Double avgLast14Milk;
+
+ @Excel(name = "过去30日均奶量")
private Double avgLast30Milk;
- // 羊只基础信息(来自 sheep_file)
+ // 羊只基础信息(来自sheep_file)
+ @Excel(name = "羊只类别")
private String sheepCategory;
+
+ @Excel(name = "生日", dateFormat = "yyyy-MM-dd")
private Date birthday;
- private Integer parity; // 当前胎次
+
+ @Excel(name = "当前胎次")
+ private Integer parity;
+
+ @Excel(name = "月龄")
private Integer monthAge;
+
+ @Excel(name = "当前体重")
private Double currentWeight;
+
+ @Excel(name = "繁育状态")
private String breedStatus;
+
+ @Excel(name = "父号")
private String fatherManageTags;
+
+ @Excel(name = "母号")
private String motherManageTags;
+
+ @Excel(name = "牧场")
private String ranchName;
+
+ @Excel(name = "家系")
private String family;
// 母亲相关字段(由已计算的母亲分析结果中取值)
+ @Excel(name = "母亲挤奶天数")
private Integer motherMilkingDays;
+
+ @Excel(name = "母亲校正奶量合计")
private Double motherSumCorrected;
+
+ @Excel(name = "母亲校正后最大胎次")
private Integer motherMaxParity;
+
+ @Excel(name = "母亲校正日平均奶量")
private Double motherAvgCorrectedDaily;
+ @Excel(name = "最后更新时间", dateFormat = "yyyy-MM-dd")
private Date lastUpdate;
// getters and setters
@@ -195,4 +258,4 @@ public class NpSheepMilkAnalysis {
public Date getLastUpdate() { return lastUpdate; }
public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; }
-}
+}
\ No newline at end of file
diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java
index 002e009..1e35d56 100644
--- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java
+++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpSheepMilkAnalysisMapper.java
@@ -9,7 +9,7 @@ import java.util.Map;
public interface NpSheepMilkAnalysisMapper {
/**
- * 按筛选天数 screenDays 统计并返回所有羊只的奶产量分析
+ * 按筛选天数screenDays统计并返回所有羊只的奶产量分析
*/
List selectAnalysisForExport(@Param("screenDays") Integer screenDays);
@@ -33,4 +33,9 @@ public interface NpSheepMilkAnalysisMapper {
*/
List