diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java index edbabb6..f2722a1 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/controller/BasSheepController.java @@ -168,7 +168,7 @@ public class BasSheepController extends BaseController { /** * 根据羊只类型ID查询羊只列表 */ - @PreAuthorize("@ss.hasPermi('sheep:sheep:query')") +// @PreAuthorize("@ss.hasPermi('sheep:sheep:queryByType')") @GetMapping("/listByTypeId") public TableDataInfo listByTypeId(Integer typeId) { if (typeId == null) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java b/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java index 92c683b..cc608df 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java @@ -103,6 +103,14 @@ public class BasSheep extends BaseEntity @Excel(name = "母号id") private Long motherId; + /** 外祖父耳号 */ + @Excel(name = "外祖父") + private String grandpa; + + /** 外祖母耳号 */ + @Excel(name = "外祖母") + private String grandma; + /** 受体id */ @Excel(name = "受体id") private Long receptorId; diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Deworm.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Deworm.java index 7db3a19..235fbac 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Deworm.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Deworm.java @@ -58,7 +58,7 @@ public class Deworm extends BaseEntity private Long deptId; /** 药品使用记录 */ - @Excel(name = "药品使用记录") +// @Excel(name = "药品使用记录") private Integer usageId; @@ -78,9 +78,28 @@ public class Deworm extends BaseEntity @Excel(name = "备注") private String comment; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; // 排序查询 private String orderByColumn; private String isAsc; + public void setGender(String gender) { + this.gender = gender; + if (gender != null && !gender.trim().isEmpty()) { + try { + Integer genderCode = Integer.valueOf(gender.trim()); + this.genderName = Gender.getDescByCode(genderCode); + } catch (NumberFormatException e) { + // 如果转换失败,设置为空或默认值 + this.genderName = null; + } + } else { + this.genderName = null; + } + } + } diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Diagnosis.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Diagnosis.java index 14cb984..cffaa39 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Diagnosis.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Diagnosis.java @@ -80,6 +80,8 @@ public class Diagnosis extends BaseEntity /** 诊疗结果 */ @Excel(name = "诊疗结果") + private String resultName; + /** 诊断结果 */ private String result; /** 开始时间 */ @@ -106,6 +108,11 @@ public class Diagnosis extends BaseEntity private String orderByColumn; private String isAsc; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; + private Long userId; private Long deptId; @@ -123,5 +130,19 @@ public class Diagnosis extends BaseEntity this.genderName = null; } } + public void setResult(String result) { + this.result = result; + if (result != null && !result.trim().isEmpty()) { + try { + Integer resultCode = Integer.valueOf(result.trim()); + this.resultName = Gender.getDescByCode(resultCode); + } catch (NumberFormatException e) { + // 如果转换失败,设置为空或默认值 + this.resultName = null; + } + } else { + this.resultName = null; + } + } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Health.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Health.java index 9eadf30..320c014 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Health.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Health.java @@ -29,7 +29,7 @@ public class Health extends BaseEntity private Date datetime; /** 羊只id */ - @Excel(name = "羊只id") +// @Excel(name = "羊只id") private Long sheepId; private Integer[] sheepIds; @@ -79,6 +79,11 @@ public class Health extends BaseEntity private String orderByColumn; private String isAsc; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; + public void setGender(String gender) { this.gender = gender; if (gender != null && !gender.trim().isEmpty()) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Immunity.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Immunity.java index 70ccaa0..9b399ee 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Immunity.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/Immunity.java @@ -28,7 +28,6 @@ public class Immunity extends BaseEntity private Long id; /** 羊只id */ - @Excel(name = "羊只id") private Long sheepId; private Integer[] sheepIds; @@ -42,7 +41,6 @@ public class Immunity extends BaseEntity @Excel(name = "品种") - private String variety; @Excel(name = "羊只类别") private String sheepType; @@ -81,6 +79,11 @@ public class Immunity extends BaseEntity private Long userId; private Long deptId; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; + // 药品使用 private List usageDetails; diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/QuarantineReport.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/QuarantineReport.java index 5b2a5f4..bb74310 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/QuarantineReport.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/QuarantineReport.java @@ -4,6 +4,8 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhyc.module.biosafety.enums.QuarantineResult; +import com.zhyc.module.biosafety.enums.QuarantineStatus; import com.zhyc.module.enums.Gender; import lombok.AllArgsConstructor; import lombok.Data; @@ -91,10 +93,12 @@ public class QuarantineReport extends BaseEntity /** 检疫结果 */ @Excel(name = "检疫结果") + private String resultName; private String result; /** 状态 */ @Excel(name = "状态") + private String statusName; private Integer status; /** 备注*/ @@ -104,6 +108,11 @@ public class QuarantineReport extends BaseEntity private Long userId; private Long deptId; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; + public void setGender(String gender) { this.gender = gender; if (gender != null && !gender.trim().isEmpty()) { @@ -118,6 +127,35 @@ public class QuarantineReport extends BaseEntity this.genderName = null; } } +// 检疫结果转换 + public void setResult(String result) { + this.result = result; + if (result != null && !result.trim().isEmpty()) { + try { + Integer resultCode = Integer.valueOf(result.trim()); + this.resultName = QuarantineResult.getDescByCode(resultCode); + } catch (NumberFormatException e) { + // 如果转换失败,设置为空或默认值 + this.resultName = null; + } + } else { + this.genderName = null; + } + } +// 检疫状态 + public void setStatus(Integer status) { + this.status = status; + if (status != null) { + try { + this.statusName = QuarantineStatus.getDescByCode(status); + } catch (NumberFormatException e) { + // 如果转换失败,设置为空或默认值 + this.statusName = null; + } + } else { + this.statusName = null; + } + } // 排序查询 private String orderByColumn; diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsage.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsage.java index 62e212f..8210e74 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsage.java +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/domain/SwMedicineUsage.java @@ -5,6 +5,8 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhyc.module.biosafety.enums.PrescriptionType; +import com.zhyc.module.biosafety.enums.TreatmentStatus; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -32,7 +34,7 @@ public class SwMedicineUsage extends BaseEntity private String name; /** 羊舍名称 */ - @Excel(name = "使用名称" ,width = 20, needMerge = true) + @Excel(name = "羊舍名称" ,width = 20, needMerge = true) private String sheepfoldName; private Integer sheepfoldId; /** 耳号 */ @@ -51,8 +53,10 @@ public class SwMedicineUsage extends BaseEntity /** 使用类型 */ @Excel(name = "使用类型",width = 20, needMerge = true) + private String useTypeName; private String useType; + private Long userId; private Long deptId; @@ -61,4 +65,17 @@ public class SwMedicineUsage extends BaseEntity private List swMedicineUsageDetailsList; + /** 状态转换 */ + public void setUseType(String useType) { + this.useType = useType; + this.useTypeName = null; + if (useType != null && !useType.trim().isEmpty()) { + try { + this.useTypeName = PrescriptionType.getDescByCode(Integer.valueOf(useType.trim())); + } catch (NumberFormatException ex) { + // 可选:记录日志、或抛业务异常 + this.useTypeName = "未知"; + } + } + } } 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 f6dce30..174889f 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 @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhyc.module.biosafety.enums.TreatmentStatus; import com.zhyc.module.enums.Gender; import lombok.AllArgsConstructor; import lombok.Data; @@ -97,22 +98,38 @@ public class Treatment extends BaseEntity private String veterinary; /** 治疗状态 */ @Excel(name = "治疗状态") + private String statusName; private String status; /** 药品使用记录id */ - @Excel(name = "药品使用记录id") + private Integer usageId; private Long userId; private Long deptId; + /** + * 是否在群查询条件(0-在群,1-离群),非数据库字段 + */ + private Integer isDelete; + + + + // 药品使用 private List usageDetails; /** 备注 */ @Excel(name = "备注") private String comment; + + + // 排序查询 + private String orderByColumn; + private String isAsc; + + /** 性别转换 */ public void setGender(String gender) { this.gender = gender; // 保留原始字符串 this.genderName = null; // 先清空 @@ -125,8 +142,18 @@ public class Treatment extends BaseEntity } } } + /** 状态转换 */ + public void setStatus(String status) { + this.status = status; + this.statusName = null; + if (status != null && !status.trim().isEmpty()) { + try { + this.statusName = TreatmentStatus.getDescByCode(Integer.valueOf(status.trim())); + } catch (NumberFormatException ex) { + // 可选:记录日志、或抛业务异常 + this.statusName = "未知"; + } + } + } - // 排序查询 - private String orderByColumn; - private String isAsc; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/DiagnosisResult.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/DiagnosisResult.java new file mode 100644 index 0000000..c4a11f0 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/DiagnosisResult.java @@ -0,0 +1,74 @@ +package com.zhyc.module.biosafety.enums; + + +/** + * 诊疗结果枚举 + */ +public enum DiagnosisResult { + + ABANDONED(0, "放弃"), + CURED(1, "已治愈"), + IN_TREATMENT(2, "治疗中"), + COMPLETED(3, "治疗完成"); + + private final int code; + private final String desc; + + DiagnosisResult(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (DiagnosisResult result : values()) { + if (result.code == code) { + return result.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static DiagnosisResult getByCode(Integer code) { + if (code == null) { + return null; + } + for (DiagnosisResult result : values()) { + if (result.code == code) { + return result; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (DiagnosisResult result : values()) { + if (result.desc.equals(desc)) { + return result.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/PrescriptionType.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/PrescriptionType.java new file mode 100644 index 0000000..dee6b45 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/PrescriptionType.java @@ -0,0 +1,75 @@ +package com.zhyc.module.biosafety.enums; + + +/** + * 处方类型枚举 + */ +public enum PrescriptionType { + + IMMUNITY(0, "免疫"), + DEWORMING(1, "驱虫"), + HEALTH_CARE(2, "保健"), + DISINFECTION(3, "消毒"), + DISEASE_TREATMENT(4, "疾病治疗"); + + private final int code; + private final String desc; + + PrescriptionType(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (PrescriptionType type : values()) { + if (type.code == code) { + return type.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static PrescriptionType getByCode(Integer code) { + if (code == null) { + return null; + } + for (PrescriptionType type : values()) { + if (type.code == code) { + return type; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (PrescriptionType type : values()) { + if (type.desc.equals(desc)) { + return type.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineResult.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineResult.java new file mode 100644 index 0000000..ead345b --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineResult.java @@ -0,0 +1,71 @@ +package com.zhyc.module.biosafety.enums; + +/** + * 检疫结果枚举 + */ +public enum QuarantineResult { + + NEGATIVE(0, "阴性"), + POSITIVE(1, "阳性"); + + private final int code; + private final String desc; + + QuarantineResult(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (QuarantineResult result : values()) { + if (result.code == code) { + return result.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static QuarantineResult getByCode(Integer code) { + if (code == null) { + return null; + } + for (QuarantineResult result : values()) { + if (result.code == code) { + return result; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (QuarantineResult result : values()) { + if (result.desc.equals(desc)) { + return result.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineStatus.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineStatus.java new file mode 100644 index 0000000..632ff46 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/QuarantineStatus.java @@ -0,0 +1,72 @@ +package com.zhyc.module.biosafety.enums; + + +/** + * 检疫状态枚举 + */ +public enum QuarantineStatus { + + PENDING(0, "送检中"), + TESTED(1, "已检测"); + + private final int code; + private final String desc; + + QuarantineStatus(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (QuarantineStatus status : values()) { + if (status.code == code) { + return status.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static QuarantineStatus getByCode(Integer code) { + if (code == null) { + return null; + } + for (QuarantineStatus status : values()) { + if (status.code == code) { + return status; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (QuarantineStatus status : values()) { + if (status.desc.equals(desc)) { + return status.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/TreatmentStatus.java b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/TreatmentStatus.java new file mode 100644 index 0000000..88351b8 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/biosafety/enums/TreatmentStatus.java @@ -0,0 +1,31 @@ +package com.zhyc.module.biosafety.enums; + +/** + * 治疗状态枚举 + */ +public enum TreatmentStatus { + + ABANDONED(-1, "放弃", 0), + IN_TREATMENT(0, "治疗中", 1), + TREATMENT_COMPLETED(1, "治疗完成", 2), + CURED(2, "已治愈", 3); + + private final int code; + private final String desc; + private final int sort; + + TreatmentStatus(int code, String desc, int sort) { + this.code = code; + this.desc = desc; + this.sort = sort; + } + + public static String getDescByCode(Integer code) { + for (TreatmentStatus status : values()) { + if (status.code == code) { + return status.desc; + } + } + return "未知"; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/common/controller/UserPostController.java b/zhyc-module/src/main/java/com/zhyc/module/common/controller/UserPostController.java index 7b63e2e..9e30cc4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/common/controller/UserPostController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/common/controller/UserPostController.java @@ -35,7 +35,14 @@ public class UserPostController { // 获取岗位(部门) @GetMapping("/getPost") public AjaxResult getPost(String postName){ - List list = postService.selectPostList(); + List list = postService.selectPostList(postName); + return AjaxResult.success(list); + } + +// 获取岗位班组 + @GetMapping("/getPostTeam") + public AjaxResult getPostTeam(){ + List list = postService.selectPostList("班"); return AjaxResult.success(list); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/common/mapper/PostMapper.java b/zhyc-module/src/main/java/com/zhyc/module/common/mapper/PostMapper.java index e2bc5d2..643a587 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/common/mapper/PostMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/common/mapper/PostMapper.java @@ -1,12 +1,29 @@ package com.zhyc.module.common.mapper; import com.zhyc.module.common.domain.Post; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; import java.util.List; public interface PostMapper { - @Select("select * from sys_post where status = '0'") - List selectPostList(); + /** + * 根据岗位名称模糊查询岗位列表 + * + * @param postName 岗位名称(可为空) + * @return 岗位列表 + */ + @Select("SELECT post_id, post_code, post_name, post_sort, status FROM sys_post WHERE post_name LIKE CONCAT('%', #{postName}, '%') AND status = '0'") + @Results({ + @Result(property = "postId", column = "post_id"), + @Result(property = "postCode", column = "post_code"), + @Result(property = "postName", column = "post_name"), + @Result(property = "postSort", column = "post_sort"), + @Result(property = "status", column = "status") + }) + List selectPostList(@Param("postName") String postName); } + diff --git a/zhyc-module/src/main/java/com/zhyc/module/common/service/PostService.java b/zhyc-module/src/main/java/com/zhyc/module/common/service/PostService.java index c7a2edf..9607a24 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/common/service/PostService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/common/service/PostService.java @@ -5,5 +5,5 @@ import com.zhyc.module.common.domain.Post; import java.util.List; public interface PostService { - List selectPostList(); + List selectPostList(String postName); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/common/service/impl/PostServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/common/service/impl/PostServiceImpl.java index 3ab72f0..9c148f6 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/common/service/impl/PostServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/common/service/impl/PostServiceImpl.java @@ -15,8 +15,8 @@ public class PostServiceImpl implements PostService { PostMapper postMapper; @Override - public List selectPostList() { - List list = postMapper.selectPostList(); + public List selectPostList(String postName) { + List list = postMapper.selectPostList(postName); return list; } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkInOutStoreController.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkInOutStoreController.java index 1d7f8e5..b689bb4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkInOutStoreController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/controller/NpMilkInOutStoreController.java @@ -4,6 +4,7 @@ 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.dairyProducts.domain.NpMilkInOutStore; // 引入实体类 import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; @@ -32,7 +33,16 @@ public class NpMilkInOutStoreController extends BaseController { @RequestParam(required=false) Date datetimeEnd ) { startPage(); - List> rows = service.selectWithDynamicColumns(datetimeStart, datetimeEnd); + // 修改:封装查询参数到实体对象,以便利用 BaseEntity 的 params 属性传递数据权限 + NpMilkInOutStore query = new NpMilkInOutStore(); + if (datetimeStart != null) { + query.getParams().put("beginTime", datetimeStart); + } + if (datetimeEnd != null) { + query.getParams().put("endTime", datetimeEnd); + } + + List> rows = service.selectWithDynamicColumns(query); return getDataTable(rows); } @@ -45,6 +55,7 @@ public class NpMilkInOutStoreController extends BaseController { service.batchInsertFromRows(list); return AjaxResult.success("导入成功"); } + /** 导出 Excel */ @PreAuthorize("@ss.hasPermi('milkInOutStore:export')") @Log(title="导出羊奶出入库", businessType=BusinessType.EXPORT) @@ -53,10 +64,20 @@ public class NpMilkInOutStoreController extends BaseController { @RequestParam(required=false) Date datetimeStart, @RequestParam(required=false) Date datetimeEnd ) { - List> rows = service.selectWithDynamicColumns(datetimeStart, datetimeEnd); + // 修改:封装查询参数到实体对象 + NpMilkInOutStore query = new NpMilkInOutStore(); + if (datetimeStart != null) { + query.getParams().put("beginTime", datetimeStart); + } + if (datetimeEnd != null) { + query.getParams().put("endTime", datetimeEnd); + } + + List> rows = service.selectWithDynamicColumns(query); // 解决方案:强制转换并压制警告 @SuppressWarnings("unchecked") ExcelUtil> util = new ExcelUtil<>((Class>) (Class) Map.class); + util.exportExcel(response, rows, "羊奶出入库数据"); } /** 获取可选列定义(饲喂来源 + 销售去向) */ @@ -65,5 +86,4 @@ public class NpMilkInOutStoreController extends BaseController { public AjaxResult getColumns(){ return AjaxResult.success(service.getAllColumnOptions()); } -} - +} \ No newline at end of file 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 3970f1e..81eb227 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 @@ -5,11 +5,20 @@ import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; -public class NpMilkProdClasses implements Serializable { +/** + * 班次奶量对象 np_milk_prod_classes + * * 修改说明:继承 BaseEntity 以支持数据权限(params.dataScope) + */ +public class NpMilkProdClasses extends BaseEntity implements Serializable { private static final long serialVersionUID = 1L; private Long id; + + // 注意:BaseEntity 中通常已包含 createTime 和 updateTime。 + // 如果父类已有,此处保留会发生字段遮蔽(Shadowing),但能保证代码兼容性。 + // 为了修复 params 报错,保留原样即可,核心是 extends BaseEntity。 private Date createTime; private Date updateTime; diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpMilkInOutStoreMapper.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpMilkInOutStoreMapper.java index 722f7c7..f341898 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpMilkInOutStoreMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/mapper/NpMilkInOutStoreMapper.java @@ -3,16 +3,16 @@ package com.zhyc.module.dairyProducts.mapper; import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore; import org.apache.ibatis.annotations.Param; -import java.util.Date; import java.util.List; import java.util.Map; public interface NpMilkInOutStoreMapper { /** * 动态列查询 + * 修改:使用 @Param("queryParams") 传递实体,包含 params.dataScope */ List> selectWithColumns( - @Param("start") Date start, @Param("end") Date end, + @Param("queryParams") NpMilkInOutStore queryParams, @Param("feedSources") List feedSources, @Param("saleDestinations") List saleDestinations ); @@ -23,7 +23,7 @@ public interface NpMilkInOutStoreMapper { int insertStore(NpMilkInOutStore store); /** - * 插入饲喂子表(已修正:增加 userId 和 deptId 参数) + * 插入饲喂子表 */ void insertFeedRecord( @Param("storeId") Integer storeId, @@ -34,7 +34,7 @@ public interface NpMilkInOutStoreMapper { ); /** - * 插入销售子表(已修正:增加 userId 和 deptId 参数) + * 插入销售子表 */ void insertSaleRecord( @Param("storeId") Integer storeId, diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpMilkInOutStoreService.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpMilkInOutStoreService.java index 5bd59d5..6d90d04 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpMilkInOutStoreService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/INpMilkInOutStoreService.java @@ -1,15 +1,16 @@ package com.zhyc.module.dairyProducts.service; +import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore; // 引入实体 import org.springframework.web.multipart.MultipartFile; -import java.util.Date; import java.util.List; import java.util.Map; public interface INpMilkInOutStoreService { - List> selectWithDynamicColumns(Date start, Date end); + // 修改参数为实体对象 + List> selectWithDynamicColumns(NpMilkInOutStore query); + List> getAllColumnOptions(); List> parseImportExcel(MultipartFile file) throws Exception; void batchInsertFromRows(List> rows) throws Exception; -} - +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpMilkInOutStoreServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpMilkInOutStoreServiceImpl.java index 7584842..b03fdf2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpMilkInOutStoreServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/dairyProducts/service/impl/NpMilkInOutStoreServiceImpl.java @@ -21,11 +21,12 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService { private NpMilkInOutStoreMapper mapper; @Override - @DataScope(deptAlias = "s", userAlias = "s") - public List> selectWithDynamicColumns(Date start, Date end) { + @DataScope(deptAlias = "s", userAlias = "s") // 启用数据权限注解 + public List> selectWithDynamicColumns(NpMilkInOutStore query) { List feed = mapper.selectFeedSources(); List sale = mapper.selectSaleDestinations(); - return mapper.selectWithColumns(start, end, feed, sale); + // 将实体对象传递给 Mapper + return mapper.selectWithColumns(query, feed, sale); } @Override @@ -35,6 +36,7 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService { m.put("sale", mapper.selectSaleDestinations()); return Collections.singletonList(m); } + @Override public List> parseImportExcel(MultipartFile file) throws Exception { // 用 Apache POI 解析 Excel 第一行标题,动态映射列名跟 unit cells @@ -61,10 +63,8 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService { @Override public void batchInsertFromRows(List> rows) throws Exception { - // === 修改开始:获取当前用户和部门ID === Long userId = SecurityUtils.getUserId(); Long deptId = SecurityUtils.getDeptId(); - // === 修改结束 === for (Map row : rows) { // 提取主表字段 @@ -76,10 +76,8 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService { // 手动填充其它主表字段,这里省略了具体的 get 调用,请根据您的 Excel 列名自行补充 // store.setColostSheep(...); - // === 修改开始:给主表实体注入用户和部门ID === store.setUserId(userId); store.setDeptId(deptId); - // === 修改结束 === mapper.insertStore(store); Integer sid = store.getId(); @@ -94,10 +92,8 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService { BigDecimal amt = new BigDecimal(ent.getValue().toString()); if (mapper.selectFeedSources().contains(col)) { - // === 修改开始:插入饲喂子表时传入 userId 和 deptId === mapper.insertFeedRecord(sid, col, amt, userId, deptId); } else if (mapper.selectSaleDestinations().contains(col)) { - // === 修改开始:插入销售子表时传入 userId 和 deptId === mapper.insertSaleRecord(sid, col, amt, userId, deptId); } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/enums/UseType.java b/zhyc-module/src/main/java/com/zhyc/module/enums/UseType.java deleted file mode 100644 index bfce1ec..0000000 --- a/zhyc-module/src/main/java/com/zhyc/module/enums/UseType.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.zhyc.module.enums; - -public enum UseType { -} diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java index f1bbb81..7970480 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyMeasureController.java @@ -74,6 +74,8 @@ public class ScBodyMeasureController extends BaseController { @Log(title = "体尺测量", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure) { + scBodyMeasure.setUserId(getUserId()); + scBodyMeasure.setDeptId(getDeptId()); return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure)); } @@ -140,6 +142,9 @@ public class ScBodyMeasureController extends BaseController { measure.setCreateTime(DateUtils.getNowDate()); measure.setCreateBy(SecurityUtils.getUsername()); + // 数据分离:自动填充当前用户和部门 + measure.setUserId(getUserId()); + measure.setDeptId(getDeptId()); scBodyMeasureService.insertScBodyMeasure(measure); successCount++; diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java index 2ee2ca7..7d78fcf 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBodyScoreController.java @@ -70,6 +70,8 @@ public class ScBodyScoreController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScBodyScore scBodyScore) { + scBodyScore.setUserId(getUserId()); + scBodyScore.setDeptId(getDeptId()); return toAjax(scBodyScoreService.insertScBodyScore(scBodyScore)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java index 670b566..3633f62 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/controller/ScBreastRatingController.java @@ -70,6 +70,8 @@ public class ScBreastRatingController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScBreastRating scBreastRating) { + scBreastRating.setUserId(getUserId()); + scBreastRating.setDeptId(getDeptId()); return toAjax(scBreastRatingService.insertScBreastRating(scBreastRating)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java index 2b1bf5b..4a1ae39 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyMeasure.java @@ -212,4 +212,38 @@ public class ScBodyMeasure extends BaseEntity { * 月龄查询条件(结束),非数据库字段 */ private Integer monthAgeEnd; + + @Excel(name = "月龄") + private Integer monthAge; // 测量时月龄 + + @Excel(name = "乳房深度") + private Long breastDepth; // 测量时乳房深度 + + @Excel(name = "乳头位置") + private String breastPosition; // 测量时乳头位置 + + @Excel(name = "乳头长度") + private Long breastLength; // 测量时乳头长度 + + @Excel(name = "乳房附着") + private String breastAdbere; // 测量时乳房附着 + + @Excel(name = "乳房间隔度") + private String breastSpacing; // 测量时乳房间隔度 + + @Excel(name = "乳房评分") + private Long breastScore; // 测量时乳房评分(快照) + + @Excel(name = "体况评分") + private Long bodyScore; // 测量时体况评分(快照) + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java index c37ee77..9035967 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/domain/ScBodyScore.java @@ -87,4 +87,14 @@ public class ScBodyScore extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } 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 fc0859e..e366749 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 @@ -54,33 +54,24 @@ public class ScBreastRating extends BaseEntity { @Excel(name = "事件日期") private LocalDate eventDate; - /** - * 羊舍ID - */ - private Long sheepfoldId; - @Excel(name = "羊舍") - /** 羊舍名称(用于展示) */ - private String sheepfoldName; - - /** * 乳房深度 */ @Excel(name = "乳房深度") private Long depth; - /** - * 乳房长度 - */ - @Excel(name = "乳房长度") - private Long length; - /** * 乳房位置 */ @Excel(name = "乳房位置") private String position; + /** + * 乳房长度 + */ + @Excel(name = "乳房长度") + private Long length; + /** * 乳房附着 */ @@ -100,10 +91,12 @@ public class ScBreastRating extends BaseEntity { private Long score; /** - * 备注 + * 羊舍ID */ - @Excel(name = "备注") - private String comment; + private Long sheepfoldId; + @Excel(name = "羊舍") + /** 羊舍名称(用于展示) */ + private String sheepfoldName; /** * 技术员 @@ -111,6 +104,12 @@ public class ScBreastRating extends BaseEntity { @Excel(name = "技术员") private String technician; + /** + * 备注 + */ + @Excel(name = "备注") + private String comment; + /** * 前端多耳号查询条件,非表字段 */ @@ -120,4 +119,14 @@ public class ScBreastRating extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java index 7859be9..5d0b7eb 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBodyMeasureMapper.java @@ -1,9 +1,11 @@ package com.zhyc.module.produce.bodyManage.mapper; +import java.util.Date; import java.util.List; import java.util.Map; import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure; +import com.zhyc.module.produce.bodyManage.domain.ScBreastRating; import org.apache.ibatis.annotations.Param; /** @@ -76,4 +78,6 @@ public interface ScBodyMeasureMapper * 查询繁殖状态列表 */ List> selectBreedStatusList(); + + } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java index dedcb4b..b5caa35 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/mapper/ScBreastRatingMapper.java @@ -1,5 +1,6 @@ package com.zhyc.module.produce.bodyManage.mapper; +import java.util.Date; import java.util.List; import com.zhyc.module.produce.bodyManage.domain.ScBreastRating; import org.apache.ibatis.annotations.Param; @@ -69,4 +70,12 @@ public interface ScBreastRatingMapper List selectScBreastRatingList( @Param("sc") ScBreastRating sc, @Param("manageTagsList") List manageTagsList); + + /** + * 查询指定日期前该羊只最新的乳房评分记录 + */ + ScBreastRating selectLatestBySheepIdBeforeDate( + @Param("sheepId") Long sheepId, + @Param("measureDate") Date measureDate + ); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java index 77a334b..075ccd9 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyMeasureServiceImpl.java @@ -1,35 +1,46 @@ package com.zhyc.module.produce.bodyManage.service.impl; +import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Map; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.service.IBasSheepService; +import com.zhyc.module.produce.bodyManage.domain.ScBreastRating; +import com.zhyc.module.produce.bodyManage.mapper.ScBreastRatingMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.zhyc.module.produce.bodyManage.mapper.ScBodyMeasureMapper; import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure; import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService; /** * 体尺测量Service业务层处理 - * + * * @author ruoyi * @date 2025-07-27 */ @Service -public class ScBodyMeasureServiceImpl implements IScBodyMeasureService +public class ScBodyMeasureServiceImpl implements IScBodyMeasureService { @Autowired private ScBodyMeasureMapper scBodyMeasureMapper; + @Autowired private IBasSheepService basSheepService; + + @Autowired + private ScBreastRatingMapper scBreastRatingMapper; + /** * 查询体尺测量 - * + * * @param id 体尺测量主键 * @return 体尺测量 */ @@ -41,11 +52,12 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService /** * 查询体尺测量列表 - * + * * @param scBodyMeasure 体尺测量 * @return 体尺测量 */ @Override + @DataScope(deptAlias = "sm", userAlias = "sm") public List selectScBodyMeasureList(ScBodyMeasure scBodyMeasure) { return scBodyMeasureMapper.selectScBodyMeasureList(scBodyMeasure, scBodyMeasure.getManageTagsList()); @@ -58,57 +70,164 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService /** * 新增体尺测量 + * 追根溯源原则:记录测量时刻的所有数据快照,后续羊只信息变化不影响历史记录 */ @Override + @Transactional(rollbackFor = Exception.class) public int insertScBodyMeasure(ScBodyMeasure scBodyMeasure) { + // 1. 耳号验证并获取羊只信息 String manageTags = scBodyMeasure.getManageTags(); if (StringUtils.isNotBlank(manageTags)) { - BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); if (sheep == null) { throw new RuntimeException("耳号不存在,请检查输入"); } scBodyMeasure.setSheepId(sheep.getId()); + + // 2. 固化测量时刻的基础信息(追根溯源) + fillMeasureTimeSnapshot(scBodyMeasure, sheep); } - if (scBodyMeasure.getCurrentWeight() != null) { + // 3. 设置创建信息 + scBodyMeasure.setCreateTime(DateUtils.getNowDate()); + scBodyMeasure.setCreateBy(SecurityUtils.getUsername()); + + // 4. 保存体尺测量记录 + int rows = scBodyMeasureMapper.insertScBodyMeasure(scBodyMeasure); + + // 5. 同步更新羊只当前体重(实时状态,可以更新) + if (rows > 0 && scBodyMeasure.getCurrentWeight() != null) { BasSheep updateSheep = new BasSheep(); updateSheep.setId(scBodyMeasure.getSheepId()); updateSheep.setCurrentWeight(scBodyMeasure.getCurrentWeight()); basSheepService.updateBasSheep(updateSheep); } - scBodyMeasure.setCreateTime(DateUtils.getNowDate()); - scBodyMeasure.setCreateBy(SecurityUtils.getUsername()); - return scBodyMeasureMapper.insertScBodyMeasure(scBodyMeasure); + return rows; + } + + /** + * 填充测量时刻的数据快照(追根溯源) + * 所有字段基于测量日期计算,固化存储,不受后续数据变化影响 + */ + private void fillMeasureTimeSnapshot(ScBodyMeasure measure, BasSheep sheep) { + Date measureDate = measure.getMeasureDate(); + if (measureDate == null) { + measureDate = new Date(); // 如果未指定,默认当前日期 + measure.setMeasureDate(measureDate); + } + + // ========== 1. 月龄(测量日期 - 出生日期)========== + if (sheep.getBirthday() != null) { + int monthAge = calculateMonthAge(sheep.getBirthday(), measureDate); + measure.setMonthAge(monthAge); + } + + // ========== 2. 体况评分 & 乳房评分(羊只档案当前值)========== + measure.setBodyScore(sheep.getBody()); // 测量时的体况评分 + measure.setBreastScore(sheep.getBreast()); // 测量时的乳房评分 + + // ========== 3. 时间相关天数(基于测量日期计算,非当前日期)========== + + // 配后天数 = 测量日期 - 配种日期 + if (sheep.getMatingDate() != null) { + int postMatingDay = calculateDaysDiff(sheep.getMatingDate(), measureDate); + measure.setPostMatingDay(postMatingDay); + } + + // 怀孕天数 = 测量日期 - 配种日期(如果已配种) + if (sheep.getMatingDate() != null) { + int gestationDay = calculateDaysDiff(sheep.getMatingDate(), measureDate); + measure.setGestationDay(gestationDay); + } + + // 泌乳天数 = 测量日期 - 产羔日期(如果已产羔) + if (sheep.getLambingDate() != null) { + int lactationDay = calculateDaysDiff(sheep.getLambingDate(), measureDate); + measure.setLactationDay(lactationDay); + } + + // ========== 4. 乳房详细指标(取测量日期前最新的乳房评分记录)========== + fillBreastRatingSnapshot(measure); + } + + /** + * 填充乳房评分快照(测量时刻的最新记录) + */ + private void fillBreastRatingSnapshot(ScBodyMeasure measure) { + if (measure.getSheepId() == null || measure.getMeasureDate() == null) { + return; + } + + // 查询该羊只在测量日期前最新的乳房评分记录 + ScBreastRating latestRating = scBreastRatingMapper + .selectLatestBySheepIdBeforeDate(measure.getSheepId(), measure.getMeasureDate()); + + if (latestRating != null) { + measure.setBreastDepth(latestRating.getDepth()); // 乳房深度 + measure.setBreastPosition(latestRating.getPosition()); // 乳头位置 + measure.setBreastLength(latestRating.getLength()); // 乳头长度 + measure.setBreastAdbere(latestRating.getAdbere()); // 乳房附着 + measure.setBreastSpacing(latestRating.getSpacing()); // 乳房间隔度 + // 注意:breastScore 取羊只档案的当前值,不取历史评分记录的score + } + } + + /** + * 计算月龄(精确到月) + */ + private int calculateMonthAge(Date birthday, Date measureDate) { + Calendar birthCal = Calendar.getInstance(); + birthCal.setTime(birthday); + + Calendar measureCal = Calendar.getInstance(); + measureCal.setTime(measureDate); + + int yearDiff = measureCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR); + int monthDiff = measureCal.get(Calendar.MONTH) - birthCal.get(Calendar.MONTH); + + int monthAge = yearDiff * 12 + monthDiff; + + // 如果测量日期的"日"小于出生日期的"日",则不满整月,减1 + if (measureCal.get(Calendar.DAY_OF_MONTH) < birthCal.get(Calendar.DAY_OF_MONTH)) { + monthAge--; + } + + return Math.max(0, monthAge); // 确保不为负数 + } + + /** + * 计算两个日期相差天数 + */ + private int calculateDaysDiff(Date startDate, Date endDate) { + long diffMillis = endDate.getTime() - startDate.getTime(); + return (int) (diffMillis / (1000 * 60 * 60 * 24)); } /** * 修改体尺测量 + * 注意:修改时不改变已固化的快照数据(月龄、评分等),只修改体尺测量值本身 */ @Override public int updateScBodyMeasure(ScBodyMeasure scBodyMeasure) { String manageTags = scBodyMeasure.getManageTags(); if (StringUtils.isNotBlank(manageTags)) { - BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); if (sheep == null) { throw new RuntimeException("耳号不存在,请检查输入"); } scBodyMeasure.setSheepId(sheep.getId()); } - if (scBodyMeasure.getCurrentWeight() != null) { - BasSheep updateSheep = new BasSheep(); - updateSheep.setId(scBodyMeasure.getSheepId()); - updateSheep.setCurrentWeight(scBodyMeasure.getCurrentWeight()); - basSheepService.updateBasSheep(updateSheep); - } + // 修改时不同步更新体重,避免历史记录被污染 + // 如需修改体重,应通过专门的功能或重新新增记录 return scBodyMeasureMapper.updateScBodyMeasure(scBodyMeasure); } /** * 批量删除体尺测量 - * + * * @param ids 需要删除的体尺测量主键 * @return 结果 */ @@ -120,7 +239,7 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService /** * 删除体尺测量信息 - * + * * @param id 体尺测量主键 * @return 结果 */ @@ -134,4 +253,4 @@ public class ScBodyMeasureServiceImpl implements IScBodyMeasureService public List> selectBreedStatusList() { return scBodyMeasureMapper.selectBreedStatusList(); } -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java index e25bce9..f720f08 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBodyScoreServiceImpl.java @@ -2,6 +2,7 @@ package com.zhyc.module.produce.bodyManage.service.impl; import java.util.List; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; @@ -48,6 +49,7 @@ public class ScBodyScoreServiceImpl implements IScBodyScoreService { * @return 体况评分 */ @Override + @DataScope(deptAlias = "sbs", userAlias = "sbs") public List selectScBodyScoreList(ScBodyScore scBodyScore) { return scBodyScoreMapper.selectScBodyScoreList(scBodyScore, scBodyScore.getManageTagsList()); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java index 4fd01cd..70c35c0 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/bodyManage/service/impl/ScBreastRatingServiceImpl.java @@ -3,6 +3,7 @@ package com.zhyc.module.produce.bodyManage.service.impl; import java.util.List; import java.util.Map; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; @@ -51,6 +52,7 @@ public class ScBreastRatingServiceImpl implements IScBreastRatingService { * @return 乳房评分 */ @Override + @DataScope(deptAlias = "sbr", userAlias = "sbr") public List selectScBreastRatingList(ScBreastRating scBreastRating) { return scBreastRatingMapper.selectScBreastRatingList(scBreastRating, scBreastRating.getManageTagsList()); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java index 51bc1c9..0f7a70e 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScAddSheepController.java @@ -1,6 +1,7 @@ package com.zhyc.module.produce.manage_sheep.controller; 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.common.exception.ServiceException; @@ -33,7 +34,7 @@ import static com.zhyc.common.utils.SecurityUtils.getUsername; @RestController @RequestMapping("produce/manage_sheep/add_sheep") -public class ScAddSheepController { +public class ScAddSheepController extends BaseController { @Autowired private IScAddSheepService scAddSheepService; @Autowired @@ -73,6 +74,8 @@ public class ScAddSheepController { } try { + scAddSheep.setUserId(getUserId()); + scAddSheep.setDeptId(getDeptId()); boolean success = scAddSheepService.insertScAddSheep(scAddSheep); if (success) { return success("新增成功"); @@ -134,7 +137,9 @@ public class ScAddSheepController { public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { ExcelUtil util = new ExcelUtil<>(ScAddSheep.class); List list = util.importExcel(file.getInputStream()); - String message = scAddSheepService.importSheep(list, updateSupport, getUsername()); + Long userId = getUserId(); + Long deptId = getDeptId(); + String message = scAddSheepService.importSheep(list, updateSupport, getUsername(), userId, deptId); return success(message); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java index f6f5d88..f5d25b4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeCommentController.java @@ -70,6 +70,8 @@ public class ScChangeCommentController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScChangeComment scChangeComment) { + scChangeComment.setUserId(getUserId()); + scChangeComment.setDeptId(getDeptId()); return toAjax(scChangeCommentService.insertScChangeComment(scChangeComment)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java index a1cb289..3ed4ea9 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeEarController.java @@ -86,6 +86,8 @@ public class ScChangeEarController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScChangeEar scChangeEar) { + scChangeEar.setUserId(getUserId()); + scChangeEar.setDeptId(getDeptId()); return toAjax(scChangeEarService.insertScChangeEar(scChangeEar)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java index 5bd289e..696ef2a 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScChangeVarietyController.java @@ -70,6 +70,8 @@ public class ScChangeVarietyController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScChangeVariety scChangeVariety) { + scChangeVariety.setUserId(getUserId()); + scChangeVariety.setDeptId(getDeptId()); return toAjax(scChangeVarietyService.insertScChangeVariety(scChangeVariety)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java index 192ed1f..0c55b4f 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransGroupController.java @@ -67,6 +67,8 @@ public class ScTransGroupController extends BaseController { @Log(title = "转群记录", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ScTransGroup scTransGroup) { + scTransGroup.setUserId(getUserId()); + scTransGroup.setDeptId(getDeptId()); return toAjax(scTransGroupService.insertScTransGroup(scTransGroup)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java index 5863be8..43f1dd4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/controller/ScTransitionInfoController.java @@ -68,16 +68,27 @@ public class ScTransitionInfoController extends BaseController { /** * 新增转场 */ +// @PreAuthorize("@ss.hasPermi('produce:transition_info:add')") +// @Log(title = "转场", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) { +// scTransitionInfo.setUserId(getUserId()); +// scTransitionInfo.setDeptId(getDeptId()); +// return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo)); +// } + + //批量添加转场 @PreAuthorize("@ss.hasPermi('produce:transition_info:add')") @Log(title = "转场", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody ScTransitionInfo scTransitionInfo) { - return toAjax(scTransitionInfoService.insertScTransitionInfo(scTransitionInfo)); - } - - //批量添加 @PostMapping("/batch") public AjaxResult addBatch(@RequestBody List transitionInfoList) { + Long userId = getUserId(); + Long deptId = getDeptId(); + + for (ScTransitionInfo info : transitionInfoList) { + info.setUserId(userId); + info.setDeptId(deptId); + } return toAjax(scTransitionInfoService.insertScTransitionInfoBatch(transitionInfoList)); } @@ -101,6 +112,7 @@ public class ScTransitionInfoController extends BaseController { return toAjax(scTransitionInfoService.deleteScTransitionInfoByIds(ids)); } + @PreAuthorize("@ss.hasPermi('produce:transition_info:approve')") @PutMapping("/approve") public AjaxResult approveScTransitionInfo(@RequestBody ScTransitionInfo scTransitionInfo) { int rows = scTransitionInfoService.approveScTransitionInfo(scTransitionInfo); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java index 4bb4444..a909a90 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java @@ -21,18 +21,23 @@ public class ScAddSheep extends BaseEntity { * @date 2025-07-10 */ private static final long serialVersionUID = 1L; - @Excel(name = "主键") private Integer id; - /** 羊只耳号 */ + /** + * 羊只耳号 + */ @Excel(name = "耳号") private String earNumber; - /** 牧场 */ + /** + * 牧场 + */ private Integer ranchId; @Excel(name = "牧场名称") private String ranchName; - /** 羊舍编号 */ + /** + * 羊舍编号 + */ private Integer sheepfold; private String sheepfoldName; @@ -40,62 +45,107 @@ public class ScAddSheep extends BaseEntity { @Excel(name = "羊舍名称") private String sheepfoldNameExcel; - /** 父号 */ + /** + * 父号 + */ @Excel(name = "父号") private String father; - /** 母号 */ + /** + * 母号 + */ @Excel(name = "母号") private String mother; - /** 出生体重 */ + /** + * 外祖父耳号 + */ + @Excel(name = "外祖父") + private String grandpa; + + /** + * 外祖母耳号 + */ + @Excel(name = "外祖母") + private String grandma; + + /** + * 出生体重 + */ @Excel(name = "出生体重") private BigDecimal bornWeight; - /** 出生日期 */ - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @Excel(name = "出生日期", dateFormat = "yyyy-MM-dd") - private Date birthday; - - /** 性别 1母 2公 3阉羊 */ - @Excel(name = "性别", readConverterExp = "1=母,2=公,3=阉羊") - private Integer gender; - - /** 胎次 */ - @Excel(name = "胎次") - private Integer parity; - - /** 品种id */ - private Integer varietyId; - - /** 品种名称(联表查询返回,非数据库字段) */ - @Excel(name = "品种") - private String varietyName; - - /** 羊只类别 */ - private Long typeId; - @Excel(name = "羊只类型") - private String typeName; - - /** 入群日期 */ - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @Excel(name = "入群日期", dateFormat = "yyyy-MM-dd") - private Date joinDate; - - /** 备注 */ - @Excel(name = "备注") - private String comment; - - /** 技术员 */ - @Excel(name = "技术员") - private String technician; - - /** 断奶体重(仅接收,不入库) */ + /** + * 断奶体重(仅接收,不入库) + */ @Excel(name = "断奶体重") private BigDecimal weaningWeight; private String createBy; private Date createTime; + /** + * 出生日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @Excel(name = "出生日期", dateFormat = "yyyy-MM-dd") + private Date birthday; + + /** + * 性别 1母 2公 3阉羊 + */ + @Excel(name = "性别", readConverterExp = "1=母,2=公,3=阉羊") + private Integer gender; + + /** + * 胎次 + */ + @Excel(name = "胎次") + private Integer parity; + + /** + * 品种id + */ + private Integer varietyId; + + /** + * 品种名称(联表查询返回,非数据库字段) + */ + @Excel(name = "品种") + private String varietyName; + + /** + * 羊只类别 + */ + private Long typeId; + private String typeName; + + /** + * 入群日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @Excel(name = "入群日期", dateFormat = "yyyy-MM-dd") + private Date joinDate; + + /** + * 备注 + */ + private String comment; + + /** + * 技术员 + */ + private String technician; + + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } 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 3260a90..66c7247 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 @@ -82,4 +82,14 @@ public class ScChangeComment extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java index 911a156..9db0c0d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeEar.java @@ -101,4 +101,14 @@ public class ScChangeEar extends BaseEntity { * 在群状态 0-全部 1-在群 2-不在群(列表查询用) */ private Integer inGroup; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java index d984268..92cdd55 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScChangeVariety.java @@ -88,4 +88,14 @@ public class ScChangeVariety extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java index 40b7d0b..c106749 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransGroup.java @@ -112,4 +112,14 @@ public class ScTransGroup extends BaseEntity { * 是否在群查询条件(0-在群,1-离群) */ private Integer isDelete; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java index e47bf49..d1d3a4e 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScTransitionInfo.java @@ -120,4 +120,14 @@ public class ScTransitionInfo extends BaseEntity { * 当前场区名称(展示用),非数据库字段 */ private String currentRanchName; + + /** + * 用户编号(数据分离用) + */ + private Long userId; + + /** + * 部门编号(数据分离用) + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java index 51c85f5..7f04ca2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScChangeCommentMapper.java @@ -26,7 +26,7 @@ public interface ScChangeCommentMapper * @param scChangeComment 改备注 * @return 改备注集合 */ - public List selectScChangeCommentList(ScChangeComment scChangeComment); +// public List selectScChangeCommentList(ScChangeComment scChangeComment); /** * 新增改备注 diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScTransitionInfoMapper.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScTransitionInfoMapper.java index af07511..45b5b61 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScTransitionInfoMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/mapper/ScTransitionInfoMapper.java @@ -35,7 +35,7 @@ public interface ScTransitionInfoMapper * @param scTransitionInfo 转场 * @return 结果 */ - public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo); +// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo); /** * 修改转场 diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java index e39b7c9..95201a1 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScAddSheepService.java @@ -20,7 +20,7 @@ public interface IScAddSheepService { boolean deleteScAddSheepByIds(Integer[] ids); //导入 - String importSheep(List list, boolean updateSupport, String operName); + String importSheep(List list, boolean updateSupport, String operName, Long userId, Long deptId); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScTransitionInfoService.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScTransitionInfoService.java index d4c85ea..f986ba5 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScTransitionInfoService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/IScTransitionInfoService.java @@ -33,7 +33,7 @@ public interface IScTransitionInfoService { * @param scTransitionInfo 转场 * @return 结果 */ - public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo); + // public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo); /** * 修改转场 diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java index 073a562..23949e0 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java @@ -1,5 +1,6 @@ package com.zhyc.module.produce.manage_sheep.service.impl; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.exception.ServiceException; import com.zhyc.common.utils.StringUtils; import com.zhyc.module.base.domain.BasSheepType; @@ -41,11 +42,12 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { @Autowired private IDaRanchService daRanchService; + //新增 @Override @Transactional(rollbackFor = Exception.class) public boolean insertScAddSheep(ScAddSheep scAddSheep) { - BasSheep existSheep =basSheepService.selectBasSheepByManageTags(scAddSheep.getEarNumber().trim()); + BasSheep existSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getEarNumber().trim()); if (existSheep != null) { throw new ServiceException("添加失败,耳号已存在"); } @@ -55,13 +57,30 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { BasSheep bs = new BasSheep(); bs.setManageTags(scAddSheep.getEarNumber()); -// bs.setElectronicTags(scAddSheep.getEarNumber()); bs.setRanchId(scAddSheep.getRanchId().longValue()); bs.setSheepfoldId(scAddSheep.getSheepfold().longValue()); - bs.setFatherId(null); - bs.setMotherId(null); + if (StringUtils.isNotBlank(scAddSheep.getFather())) { + BasSheep fatherSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getFather().trim()); + if (fatherSheep == null) { + throw new ServiceException("父号【" + scAddSheep.getFather() + "】不存在"); + } + bs.setFatherId(fatherSheep.getId()); + } + if (StringUtils.isNotBlank(scAddSheep.getMother())) { + BasSheep motherSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getMother().trim()); + if (motherSheep == null) { + throw new ServiceException("母号【" + scAddSheep.getMother() + "】不存在"); + } + bs.setMotherId(motherSheep.getId()); + } + bs.setGrandpa(scAddSheep.getGrandpa()); + bs.setGrandma(scAddSheep.getGrandma()); bs.setBirthWeight(scAddSheep.getBornWeight().longValue()); - bs.setWeaningWeight(scAddSheep.getWeaningWeight().longValue()); + if (scAddSheep.getWeaningWeight() != null) { + bs.setWeaningWeight(scAddSheep.getWeaningWeight().longValue()); + } else { + bs.setWeaningWeight(null); + } bs.setSource(String.valueOf(2)); bs.setBirthday(scAddSheep.getBirthday()); bs.setGender(scAddSheep.getGender().longValue()); @@ -86,6 +105,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { //查询 @Override + @DataScope(deptAlias = "sas", userAlias = "sas") public List selectScAddSheepList(ScAddSheep scAddSheep) { return scAddSheepMapper.selectScAddSheepList(scAddSheep); } @@ -105,7 +125,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { //导入羊只 @Override @Transactional(rollbackFor = Exception.class) - public String importSheep(List list, boolean updateSupport, String operName) { + public String importSheep(List list, boolean updateSupport, String operName, Long userId, Long deptId) { if (list == null || list.isEmpty()) { throw new ServiceException("导入数据不能为空!"); } @@ -205,6 +225,26 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { .append("】"); continue; } + if (StringUtils.isNotBlank(sheep.getFather())) { + BasSheep father = basSheepService.selectBasSheepByManageTags(sheep.getFather().trim()); + if (father == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:父号不存在【").append(sheep.getFather()).append("】"); + continue; + } + } + + if (StringUtils.isNotBlank(sheep.getMother())) { + BasSheep mother = basSheepService.selectBasSheepByManageTags(sheep.getMother().trim()); + if (mother == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:母号不存在【").append(sheep.getMother()).append("】"); + continue; + } + } + // 数据分离:设置用户和部门 + sheep.setUserId(userId); + sheep.setDeptId(deptId); if (updateSupport && sheep.getId() != null) { sheep.setUpdateBy(operName); @@ -229,6 +269,4 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { } return "导入成功!共 " + success + " 条"; } - - } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java index 9d582d4..67f9ee2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeCommentServiceImpl.java @@ -3,6 +3,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl; import java.util.Date; import java.util.List; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; import com.zhyc.module.base.domain.BasSheep; @@ -47,10 +48,12 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService * @return 改备注 */ @Override + @DataScope(deptAlias = "scc", userAlias = "scc") public List selectScChangeCommentList(ScChangeComment scChangeComment) { // 把实体和独立参数一起传过去 - return scChangeCommentMapper.selectScChangeCommentList(scChangeComment, + return scChangeCommentMapper.selectScChangeCommentList( + scChangeComment, scChangeComment.getManageTagsList()); } @Override @@ -73,12 +76,6 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService if (scChangeComment.getEventDate() == null) { throw new RuntimeException("事件日期不能为空"); } - scChangeComment.setCreateTime(new Date()); - scChangeComment.setCreateBy(SecurityUtils.getUsername()); - int rows = scChangeCommentMapper.insertScChangeComment(scChangeComment); - if (rows <= 0) { - return rows; - } String manageTags = scChangeComment.getManageTags(); BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); @@ -86,6 +83,16 @@ public class ScChangeCommentServiceImpl implements IScChangeCommentService throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新备注"); } + scChangeComment.setSheepId(String.valueOf(sheep.getId())); + scChangeComment.setOldComment(sheep.getComment()); + scChangeComment.setCreateTime(new Date()); + scChangeComment.setCreateBy(SecurityUtils.getUsername()); + + int rows = scChangeCommentMapper.insertScChangeComment(scChangeComment); + if (rows <= 0) { + return rows; + } + sheep.setComment(scChangeComment.getNewComment()); basSheepService.updateBasSheep(sheep); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java index fd968ff..b025041 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeEarServiceImpl.java @@ -1,6 +1,8 @@ package com.zhyc.module.produce.manage_sheep.service.impl; import java.util.List; + +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; @@ -66,6 +68,7 @@ public class ScChangeEarServiceImpl implements IScChangeEarService * @return 修改电子耳号记录 */ @Override + @DataScope(deptAlias = "sce", userAlias = "sce") public List selectScChangeEarList(ScChangeEar scChangeEar) { return scChangeEarMapper.selectScChangeEarList(scChangeEar, scChangeEar.getManageTagsList()); @@ -91,9 +94,6 @@ public class ScChangeEarServiceImpl implements IScChangeEarService if (scChangeEar.getSheepId() == null) { throw new RuntimeException("未找到对应的羊只ID"); } - if (StringUtils.isBlank(scChangeEar.getComment())) { - throw new RuntimeException("备注不能为空"); - } BasSheep sheep = basSheepService.selectBasSheepById(scChangeEar.getSheepId()); if (sheep == null) { @@ -122,11 +122,6 @@ public class ScChangeEarServiceImpl implements IScChangeEarService sheep.setManageTags(scChangeEar.getNewTag()); } - // 同步更新羊只主表备注 - if (StringUtils.isNotBlank(scChangeEar.getComment())) { - sheep.setComment(scChangeEar.getComment()); - } - basSheepService.updateBasSheep(sheep); return rows; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java index be56bde..e8fac47 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScChangeVarietyServiceImpl.java @@ -3,6 +3,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl; import java.util.Date; import java.util.List; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; import com.zhyc.module.base.domain.BasSheep; @@ -50,6 +51,7 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService * @return 改品种记录 */ @Override + @DataScope(deptAlias = "scv", userAlias = "scv") public List selectScChangeVarietyList(ScChangeVariety scChangeVariety) { return scChangeVarietyMapper.selectScChangeVarietyList(scChangeVariety, @@ -66,9 +68,29 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService @Transactional(rollbackFor = Exception.class) public int insertScChangeVariety(ScChangeVariety scChangeVariety) { + // ✅ 第1步:先查羊只(移到 insert 之前!) + String manageTags = scChangeVariety.getManageTags(); + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); + if (sheep == null) { + throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新品种"); + } + + // ✅ 第2步:设置所有字段(关键!) + scChangeVariety.setSheepId(sheep.getId().intValue()); // 设置羊只ID + + // 查询当前品种作为旧品种(如果前端没传) + if (StringUtils.isBlank(scChangeVariety.getVarietyOld())) { + // ✅ 修正:使用正确的方法名 selectBasSheepVarietyById + BasSheepVariety oldVariety = varietyService.selectBasSheepVarietyById(sheep.getVarietyId()); + if (oldVariety != null) { + scChangeVariety.setVarietyOld(oldVariety.getVariety()); + } + } + scChangeVariety.setCreateTime(new Date()); scChangeVariety.setCreateBy(SecurityUtils.getUsername()); + // 校验 if (StringUtils.isBlank(scChangeVariety.getTechnician())) { throw new RuntimeException("技术员不能为空"); } @@ -76,17 +98,13 @@ public class ScChangeVarietyServiceImpl implements IScChangeVarietyService throw new RuntimeException("事件日期不能为空"); } + // ✅ 第3步:再执行 insert(此时所有字段都有值了) int rows = scChangeVarietyMapper.insertScChangeVariety(scChangeVariety); if (rows <= 0) { return rows; } - String manageTags = scChangeVariety.getManageTags(); - BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); - if (sheep == null) { - throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只,无法更新品种"); - } - + // 第4步:更新羊只品种(保持你的原逻辑) String newVarietyName = scChangeVariety.getVarietyNew(); BasSheepVariety newVariety = varietyService.selectByVarietyName(newVarietyName); if (newVariety == null) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java index f78e247..7910cb4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransGroupServiceImpl.java @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; +import com.zhyc.common.utils.StringUtils; import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.mapper.BasSheepMapper; import com.zhyc.module.base.service.IBasSheepService; @@ -54,6 +56,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService { * @return 转群记录 */ @Override + @DataScope(deptAlias = "tg", userAlias = "tg") public List selectScTransGroupList(ScTransGroup scTransGroup) { List list = scTransGroupMapper.selectScTransGroupList(scTransGroup, scTransGroup.getManageTagsList()); @@ -74,8 +77,28 @@ public class ScTransGroupServiceImpl implements IScTransGroupService { @Override @Transactional(rollbackFor = Exception.class) public int insertScTransGroup(ScTransGroup scTransGroup) { + // 1. 根据耳号查询羊只信息,填充 sheepId、varietyId 等字段 + String manageTags = scTransGroup.getManageTags(); + if (StringUtils.isNotBlank(manageTags)) { + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); + if (sheep == null) { + throw new RuntimeException("耳号不存在,请检查输入"); + } + scTransGroup.setSheepId(sheep.getId().intValue()); + scTransGroup.setVarietyId(sheep.getVarietyId()); + // 转出羊舍取羊只当前所在羊舍 + scTransGroup.setFoldFrom(String.valueOf(sheep.getSheepfoldId())); + } else { + throw new RuntimeException("耳号不能为空"); + } + + // 2. 设置创建信息 scTransGroup.setCreateTime(DateUtils.getNowDate()); scTransGroup.setCreateBy(SecurityUtils.getUsername()); + + // 3. 数据分离字段已在 Controller 设置,这里不需要再设置 + + // 4. 插入数据库 int rows = scTransGroupMapper.insertScTransGroup(scTransGroup); if (rows > 0) { try { diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java index ceafa11..719d2c4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.zhyc.module.produce.manage_sheep.service.impl; import java.util.*; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.StringUtils; @@ -53,6 +54,7 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService * @return 转场 */ @Override + @DataScope(deptAlias = "t", userAlias = "t") public List selectScTransitionInfoList(ScTransitionInfo scTransitionInfo) { return scTransitionInfoMapper.selectScTransitionInfoList(scTransitionInfo, @@ -65,13 +67,36 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService * @param scTransitionInfo 转场 * @return 结果 */ - @Override - public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo) - { - scTransitionInfo.setStatus(0); - scTransitionInfo.setCreateTime(DateUtils.getNowDate()); - return scTransitionInfoMapper.insertScTransitionInfo(scTransitionInfo); - } +// @Override +// @Transactional(rollbackFor = Exception.class) +// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo) { +// // 根据耳号查询羊只信息 +// String manageTags = scTransitionInfo.getManageTags(); +// if (StringUtils.isNotBlank(manageTags)) { +// BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); +// if (sheep == null) { +// throw new RuntimeException("耳号不存在,请检查输入"); +// } +// scTransitionInfo.setSheepId(sheep.getId().intValue()); +// scTransitionInfo.setVarietyId(sheep.getVarietyId()); +// if (scTransitionInfo.getSheepfoldId() == null && sheep.getSheepfoldId() != null) { +// scTransitionInfo.setSheepfoldId(sheep.getSheepfoldId()); +// } +// if (StringUtils.isBlank(scTransitionInfo.getTransFrom()) && sheep.getRanchId() != null) { +// DaRanch ranch = daRanchService.selectDaRanchById(sheep.getRanchId()); +// if (ranch != null) { +// scTransitionInfo.setTransFrom(ranch.getRanch()); +// } +// } +// } else { +// throw new RuntimeException("耳号不能为空"); +// } +// +// scTransitionInfo.setStatus(0); +// scTransitionInfo.setCreateTime(DateUtils.getNowDate()); +// return scTransitionInfoMapper.insertScTransitionInfo(scTransitionInfo); +// } + /** * 修改转场 @@ -110,11 +135,34 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService } @Override + @Transactional(rollbackFor = Exception.class) public int insertScTransitionInfoBatch(List transitionInfoList) { String username = SecurityUtils.getUsername(); Date now = DateUtils.getNowDate(); for (ScTransitionInfo info : transitionInfoList) { + // 每条记录根据耳号查询羊只信息 + String manageTags = info.getManageTags(); + if (StringUtils.isNotBlank(manageTags)) { + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); + if (sheep == null) { + throw new RuntimeException("耳号 " + manageTags + " 不存在,请检查输入"); + } + info.setSheepId(sheep.getId().intValue()); + info.setVarietyId(sheep.getVarietyId()); + if (info.getSheepfoldId() == null && sheep.getSheepfoldId() != null) { + info.setSheepfoldId(sheep.getSheepfoldId()); + } + if (StringUtils.isBlank(info.getTransFrom()) && sheep.getRanchId() != null) { + DaRanch ranch = daRanchService.selectDaRanchById(sheep.getRanchId()); + if (ranch != null) { + info.setTransFrom(ranch.getRanch()); + } + } + } else { + throw new RuntimeException("耳号不能为空"); + } + info.setCreateBy(username); info.setCreateTime(now); info.setStatus(0); @@ -187,7 +235,7 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService BasSheep upd = new BasSheep(); upd.setId(sheep.getId()); upd.setRanchId(targetRanchId); - upd.setSheepfoldId(targetSheepfoldId); // 真正换舍 + upd.setSheepfoldId(targetSheepfoldId); basSheepMapper.updateBasSheep(upd); } } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java index 57a0411..d4ae1b8 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScCastrateController.java @@ -71,6 +71,8 @@ public class ScCastrateController extends BaseController @PostMapping public AjaxResult add(@RequestBody ScCastrate scCastrate) { + scCastrate.setUserId(getUserId()); + scCastrate.setDeptId(getDeptId()); return toAjax(scCastrateService.insertScCastrate(scCastrate)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java index fb20b18..208ade3 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/controller/ScFixHoofController.java @@ -78,7 +78,8 @@ public class ScFixHoofController extends BaseController Long sheepId = scFixHoofService.findIdByManageTags(dto.getManageTags()); dto.setSheepId(sheepId.intValue()); } - + dto.setUserId(getUserId()); + dto.setDeptId(getDeptId()); // 保存修蹄记录 scFixHoofService.insertScFixHoof(dto); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java index f2bfc4d..f97a8a2 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScCastrate.java @@ -34,20 +34,6 @@ public class ScCastrate extends BaseEntity { @Excel(name = "耳号") private String manageTags; - /** - * 事件类型 - */ - @Excel(name = "事件类型") - private String eventType; - - /** - * 羊舍id - */ - private Long sheepfold; - - @Excel(name = "羊舍名称") - private String sheepfoldName; - /** * 品种id */ @@ -60,10 +46,25 @@ public class ScCastrate extends BaseEntity { private String varietyName; /** - * 备注 + * 事件类型 */ - @Excel(name = "备注") - private String comment; + @Excel(name = "事件类型") + private String eventType; + + /** + * 去势日期 + */ + @Excel(name = "去势日期", width = 15, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private String eventDate; + + /** + * 羊舍id + */ + private Long sheepfold; + + @Excel(name = "羊舍名称") + private String sheepfoldName; /** * 技术员 @@ -72,11 +73,10 @@ public class ScCastrate extends BaseEntity { private String technician; /** - * 事件日期 + * 备注 */ - @Excel(name = "事件日期", width = 15, dateFormat = "yyyy-MM-dd") - @JsonFormat(pattern = "yyyy-MM-dd") - private String eventDate; + @Excel(name = "备注") + private String comment; /** * 前端多耳号查询条件,非表字段 @@ -87,4 +87,14 @@ public class ScCastrate extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java index 70867f0..0329a66 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/domain/ScFixHoof.java @@ -89,4 +89,14 @@ public class ScFixHoof extends BaseEntity { * 是否在群查询条件(0-在群,1-离群),非数据库字段 */ private Integer isDelete; + + /** + * 用户编号 + */ + private Long userId; + + /** + * 部门编号 + */ + private Long deptId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java index f000dd3..226de72 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScCastrateServiceImpl.java @@ -2,6 +2,7 @@ package com.zhyc.module.produce.other.service.impl; import java.util.List; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import com.zhyc.module.base.domain.BasSheep; @@ -11,6 +12,7 @@ import com.zhyc.module.produce.other.mapper.ScCastrateMapper; import com.zhyc.module.produce.other.service.IScCastrateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 去势Service业务层处理 @@ -43,6 +45,7 @@ public class ScCastrateServiceImpl implements IScCastrateService { * @return 去势 */ @Override + @DataScope(deptAlias = "sc", userAlias = "sc") public List selectScCastrateList(ScCastrate scCastrate) { return scCastrateMapper.selectScCastrateList(scCastrate, scCastrate.getManageTagsList()); @@ -55,22 +58,33 @@ public class ScCastrateServiceImpl implements IScCastrateService { * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) public int insertScCastrate(ScCastrate scCastrate) { + // ✅ 第1步:先根据耳号查羊只(确保存在且获取完整信息) + String manageTags = scCastrate.getManageTags(); + BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags); + if (sheep == null) { + throw new RuntimeException("未找到耳号为【" + manageTags + "】的羊只"); + } + + // ✅ 第2步:设置 sheepId 和其他字段(关键!) + scCastrate.setSheepId(String.valueOf(sheep.getId())); + scCastrate.setVarietyId(sheep.getVarietyId()); // 品种ID也设置 + scCastrate.setSheepfold(sheep.getSheepfoldId()); // 羊舍ID也设置 + scCastrate.setCreateTime(DateUtils.getNowDate()); scCastrate.setCreateBy(SecurityUtils.getUsername()); - int result = scCastrateMapper.insertScCastrate(scCastrate); - if (result > 0 && scCastrate.getSheepId() != null) { - try { - BasSheep sheep = new BasSheep(); - sheep.setId(Long.parseLong(scCastrate.getSheepId())); - sheep.setGender(3L); - basSheepService.updateBasSheep(sheep); - } catch (Exception e) { - throw new RuntimeException("去势成功,但更新羊只性别失败,请重试"); - } + // ✅ 第3步:再执行 insert(此时所有字段都有值了) + int result = scCastrateMapper.insertScCastrate(scCastrate); + if (result <= 0) { + return result; } + // 第4步:更新羊只性别为去势(3) + sheep.setGender(3L); + basSheepService.updateBasSheep(sheep); + return result; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java index ed77ff9..fba20cf 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/other/service/impl/ScFixHoofServiceImpl.java @@ -2,6 +2,7 @@ package com.zhyc.module.produce.other.service.impl; import java.util.List; +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.exception.ServiceException; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; @@ -14,6 +15,7 @@ import com.zhyc.module.produce.other.mapper.ScFixHoofMapper; import com.zhyc.module.produce.other.service.IScFixHoofService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 修蹄Service业务层处理 @@ -50,6 +52,7 @@ public class ScFixHoofServiceImpl implements IScFixHoofService { * @return 修蹄 */ @Override + @DataScope(deptAlias = "fh", userAlias = "fh") public List selectScFixHoofList(ScFixHoof scFixHoof) { return scFixHoofMapper.selectScFixHoofList(scFixHoof, scFixHoof.getManageTagsList()); @@ -63,13 +66,21 @@ public class ScFixHoofServiceImpl implements IScFixHoofService { * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) // ✅ 添加事务 public int insertScFixHoof(ScFixHoof scFixHoof) { + // ✅ 查羊只(已有) BasSheep sheep = basSheepMapper.selectBasSheepById(scFixHoof.getSheepId().longValue()); if (sheep == null) { throw new ServiceException("该羊只ID不存在,请检查后再添加"); } + + // ✅ 关键:设置 sheepfold 和 varietyId(你漏了!) + scFixHoof.setSheepfold(sheep.getSheepfoldId().intValue()); + scFixHoof.setVarietyId(sheep.getVarietyId()); + scFixHoof.setCreateTime(DateUtils.getNowDate()); scFixHoof.setCreateBy(SecurityUtils.getUsername()); + return scFixHoofMapper.insertScFixHoof(scFixHoof); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java index 5fc7735..0c09308 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/controller/SxCustomerController.java @@ -1,27 +1,44 @@ package com.zhyc.module.sale.controller; import java.util.List; +import java.util.Date; // 【修改点1】新增导入Date包 import java.util.stream.Collectors; 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.*; +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.sale.domain.SxCustomer; -import com.zhyc.module.sale.domain.SxCustomerExport; // 新增导入 +import com.zhyc.module.sale.domain.SxCustomerExport; import com.zhyc.module.sale.service.ISxCustomerService; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.core.page.TableDataInfo; +/** + * 客户管理Controller + * + * @author ruoyi + * @date 2025-08-18 + */ @RestController @RequestMapping("/customer/customer") public class SxCustomerController extends BaseController { @Autowired private ISxCustomerService sxCustomerService; + /** + * 查询客户管理列表 + */ @PreAuthorize("@ss.hasPermi('customer:customer:list')") @GetMapping("/list") public TableDataInfo list(SxCustomer sxCustomer) { @@ -30,6 +47,9 @@ public class SxCustomerController extends BaseController { return getDataTable(list); } + /** + * 导出客户管理列表 + */ @PreAuthorize("@ss.hasPermi('customer:customer:export')") @Log(title = "客户管理", businessType = BusinessType.EXPORT) @PostMapping("/export") @@ -41,14 +61,22 @@ public class SxCustomerController extends BaseController { SxCustomerExport exportItem = new SxCustomerExport(); exportItem.setName(customer.getName()); exportItem.setPhone(customer.getPhone()); - // 拼接完整地址 - exportItem.setFullAddress( - (customer.getProvince() != null ? customer.getProvince() : "") + - (customer.getCity() != null ? customer.getCity() : "") + - (customer.getDistrict() != null ? customer.getDistrict() : "") + - (customer.getAddress() != null ? customer.getAddress() : "") - ); - exportItem.setRemark(customer.getRemark()); + + // 拼接所在地区 (省 + 市 + 区) + String area = (customer.getProvince() != null ? customer.getProvince() : "") + + (customer.getCity() != null ? customer.getCity() : "") + + (customer.getDistrict() != null ? customer.getDistrict() : ""); + exportItem.setArea(area); + + // 详细地址 + exportItem.setAddress(customer.getAddress()); + + // 创建人 (从BaseEntity获取) + exportItem.setCreateBy(customer.getCreateBy()); + + // 创建日期 (从BaseEntity获取) + exportItem.setCreateTime(customer.getCreateTime()); + return exportItem; }).collect(Collectors.toList()); @@ -56,29 +84,54 @@ public class SxCustomerController extends BaseController { util.exportExcel(response, exportList, "客户管理数据"); } + /** + * 获取客户管理详细信息 + */ @PreAuthorize("@ss.hasPermi('customer:customer:query')") - @GetMapping("/{id}") - public AjaxResult getInfo(@PathVariable Long id) { + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(sxCustomerService.selectSxCustomerById(id)); } + /** + * 新增客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:add')") @Log(title = "客户管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SxCustomer sxCustomer) { - // 【新增】自动填充当前登录用户的 userId 和 deptId + // 自动填充当前登录用户的 userId 和 deptId sxCustomer.setUserId(getUserId()); sxCustomer.setDeptId(getDeptId()); + + // 自动填充创建人 + sxCustomer.setCreateBy(getUsername()); + + // 【修改点2】自动填充创建时间为当前时间 + sxCustomer.setCreateTime(new Date()); + return toAjax(sxCustomerService.insertSxCustomer(sxCustomer)); } + /** + * 修改客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:edit')") @Log(title = "客户管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SxCustomer sxCustomer) { + // 自动填充更新人 + sxCustomer.setUpdateBy(getUsername()); + + // 【修改点3】自动填充更新时间为当前时间 + sxCustomer.setUpdateTime(new Date()); + return toAjax(sxCustomerService.updateSxCustomer(sxCustomer)); } + /** + * 删除客户管理 + */ @PreAuthorize("@ss.hasPermi('customer:customer:remove')") @Log(title = "客户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") 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 index 5cef249..7f93c77 100644 --- 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 @@ -1,6 +1,7 @@ package com.zhyc.module.sale.controller; import java.util.List; +import java.util.Date; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -65,7 +66,7 @@ public class SxSheepSaleController extends BaseController { public AjaxResult getInfo(@PathVariable("id") Long id) { SxSheepSale sxSheepSale = sxSheepSaleService.selectSxSheepSaleById(id); // 将数据库中的逗号分隔的耳号字符串转换为列表 - if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) { + if (sxSheepSale != null && sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) { sxSheepSale.setBsManageTagsList(java.util.Arrays.asList(sxSheepSale.getBsManageTags().split(","))); } return success(sxSheepSale); @@ -81,6 +82,11 @@ public class SxSheepSaleController extends BaseController { // 【新增】自动填充当前登录用户的 userId 和 deptId sxSheepSale.setUserId(getUserId()); sxSheepSale.setDeptId(getDeptId()); + + // 【新增】自动填充创建人和创建时间,以便列表查询时显示 + sxSheepSale.setCreatedBy(getUserId()); + sxSheepSale.setCreatedAt(new Date()); + return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale)); } @@ -117,4 +123,26 @@ public class SxSheepSaleController extends BaseController { } return AjaxResult.success(sheepInfo); } + + /** + * 根据羊舍ID获取羊只耳号列表 + */ + @GetMapping("/listSheepBySheepfoldId") + public AjaxResult listSheepBySheepfoldId(@RequestParam Long sheepfoldId) { + List list = sxSheepSaleService.selectSheepTagsBySheepfoldId(sheepfoldId); + return AjaxResult.success(list); + } + + /** + * 【新增】搜索耳号(模糊查询) + */ + @GetMapping("/searchEarNumbers") + public AjaxResult searchEarNumbers(@RequestParam("query") String query) { + try { + List earNumbers = sxSheepSaleService.searchEarNumbers(query); + return success(earNumbers); + } catch (Exception e) { + return error("搜索耳号失败:" + e.getMessage()); + } + } } \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java index c6f717b..db96f1d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java +++ b/zhyc-module/src/main/java/com/zhyc/module/sale/domain/SxCustomer.java @@ -122,6 +122,7 @@ public class SxCustomer extends BaseEntity { @Override public String toString() { + // 修改:补充 BaseEntity 中的创建人、创建时间等重要字段,便于日志排查 return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("name", getName()) @@ -133,6 +134,10 @@ public class SxCustomer extends BaseEntity { .append("remark", getRemark()) .append("userId", getUserId()) .append("deptId", getDeptId()) + .append("createBy", getCreateBy()) // 补充创建人 + .append("createTime", getCreateTime()) // 补充创建时间 + .append("updateBy", getUpdateBy()) // 补充更新人 + .append("updateTime", getUpdateTime()) // 补充更新时间 .toString(); } } \ 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 index 168563c..916c461 100644 --- 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 @@ -1,7 +1,11 @@ package com.zhyc.module.sale.domain; import com.zhyc.common.annotation.Excel; +import java.util.Date; +/** + * 客户管理导出对象 + */ public class SxCustomerExport { @Excel(name = "客户名称") private String name; @@ -9,11 +13,23 @@ public class SxCustomerExport { @Excel(name = "客户电话") private String phone; - @Excel(name = "客户地址") - private String fullAddress; + /** 新增:所在地区 */ + @Excel(name = "所在地区") + private String area; - @Excel(name = "备注") - private String remark; + /** 新增:详细地址 */ + @Excel(name = "详细地址") + private String address; + + /** 新增:创建人 */ + @Excel(name = "创建人") + private String createBy; + + /** 新增:创建日期 */ + @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date createTime; + + // --- 以下是 Getter 和 Setter 方法,必须包含 --- public String getName() { return name; @@ -31,19 +47,35 @@ public class SxCustomerExport { this.phone = phone; } - public String getFullAddress() { - return fullAddress; + public String getArea() { + return area; } - public void setFullAddress(String fullAddress) { - this.fullAddress = fullAddress; + public void setArea(String area) { + this.area = area; } - public String getRemark() { - return remark; + public String getAddress() { + return address; } - public void setRemark(String remark) { - this.remark = remark; + public void setAddress(String address) { + this.address = address; } -} + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} \ 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 index 892727e..e3e0908 100644 --- 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 @@ -25,46 +25,10 @@ public class SxSheepSale extends BaseEntity { @Excel(name = "耳号") private String bsManageTags; - /** 羊舍ID(当时销售的羊舍) */ - @Excel(name = "羊舍ID", readConverterExp = "当=时销售的羊舍") - private Long sheepfoldId; - /** 品种快照 */ - @Excel(name = "品种快照") + @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; @@ -74,6 +38,26 @@ public class SxSheepSale extends BaseEntity { @Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd") private Date saleDate; + /** 羊只类别快照 */ + @Excel(name = "羊只类别") + private String sheepName; + + /** 性别快照 */ + @Excel(name = "性别") + private String gender; + + /** 月龄快照 */ + @Excel(name = "月龄") + private Long monthAge; + + /** 胎次快照 */ + @Excel(name = "胎次") + private Long parity; + + /** 【新增】当前重量(档案关联生成) */ + @Excel(name = "当前重量(kg)") + private BigDecimal currentWeight; + /** 计价方式 */ @Excel(name = "计价方式") private String pricingMethod; @@ -82,45 +66,37 @@ public class SxSheepSale extends BaseEntity { @Excel(name = "单价") private BigDecimal unitPrice; - /** 总价(自动计算) */ - @Excel(name = "总价", readConverterExp = "自=动计算") - private BigDecimal totalPrice; - - /** 总体重(按体重时输入) */ - @Excel(name = "总体重", readConverterExp = "按=体重时输入") - private BigDecimal totalWeight; - - /** 平均体重(自动) */ - @Excel(name = "平均体重", readConverterExp = "自=动") + /** 重量(单只羊重量:单只时为总体重,多只时为平均重) - 对应数据库 avg_weight */ + @Excel(name = "重量(kg)") private BigDecimal avgWeight; - /** 平均单只价格(自动) */ - @Excel(name = "平均单只价格", readConverterExp = "自=动") + /** 单只羊价格(单只羊销售时填的总价或计算的总价;多只羊销售时计算出每只羊的平均价格) */ + @Excel(name = "单只羊价格(元)") private BigDecimal avgPricePerSheep; /** 销售类别(dict_type = sale_type) */ - @Excel(name = "销售类别", readConverterExp = "d=ict_type,==,s=ale_type") + @Excel(name = "销售类别", dictType = "sale_type") private String saleType; - /** 疾病类型(dict_type = disea_type) */ - @Excel(name = "疾病类型", readConverterExp = "d=ict_type,==,d=isea_type") - private String diseaseType; + /** 【非数据库字段】客户名称 */ + @Excel(name = "客户名称") + private String customerName; - /** 次要原因 */ - @Excel(name = "次要原因") - private String secondaryReason; + /** 【非数据库字段】客户电话 */ + @Excel(name = "客户电话") + private String customerPhone; - /** 班组(dict_type = group) */ - @Excel(name = "班组", readConverterExp = "d=ict_type,==,g=roup") - private String groupCode; + /** 【新增】【非数据库字段】所在地区 */ + @Excel(name = "所在地区") + private String customerArea; - /** 客户ID(sx_customer.id) */ - @Excel(name = "客户ID", readConverterExp = "s=x_customer.id") - private Long customerId; + /** 【非数据库字段】客户地址 */ + @Excel(name = "详细地址") + private String customerAddress; - /** 销售人员ID(sys_user.id) */ - @Excel(name = "销售人员ID", readConverterExp = "s=ys_user.id") - private Long salesPersonId; + /** 【非数据库字段】销售人员姓名 */ + @Excel(name = "销售人员") + private String salesPersonName; /** 检疫证号 */ @Excel(name = "检疫证号") @@ -130,48 +106,91 @@ public class SxSheepSale extends BaseEntity { @Excel(name = "审批编号") private String approvalNo; - /** 技术员ID(sys_user.id) */ - @Excel(name = "技术员ID", readConverterExp = "s=ys_user.id") - private Long technicianId; + /** 疾病类型(dict_type = disease_type) */ + @Excel(name = "疾病类型", dictType = "disease_type") + private String diseaseType; - /** 处理人ID(sys_user.id) */ - @Excel(name = "处理人ID", readConverterExp = "s=ys_user.id") - private Long handlerId; + /** 次要原因 */ + @Excel(name = "次要原因") + private String secondaryReason; - /** 创建人ID(sys_user.id) */ - @Excel(name = "创建人ID", readConverterExp = "s=ys_user.id") - private Long createdBy; + /** 【非数据库字段】羊舍名称 */ + @Excel(name = "羊舍") + private String sheepfoldName; + + /** 班组(dict_type = group) */ + @Excel(name = "班组", dictType = "group") + private String groupCode; + + /** 繁育状态快照 */ + @Excel(name = "繁育状态") + private String breed; + + /** 产后天数快照 */ + @Excel(name = "销售时产后天数") + private Long postLambingDay; + + /** 泌乳天数快照 */ + @Excel(name = "销售时泌乳天数") + private Long lactationDay; + + /** 怀孕天数快照 */ + @Excel(name = "销售时怀孕天数") + private Long lambingDay; + + /** 【非数据库字段】技术员姓名 */ + @Excel(name = "技术员") + private String technicianName; + + /** 【非数据库字段】处理人姓名 */ + @Excel(name = "处理人") + private String handlerName; + + /** 【非数据库字段】创建人姓名 */ + @Excel(name = "创建人") + private String createdByName; /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") private Date createdAt; + // --- 以下字段在导出中不显示,但在业务中需要 --- + + /** 总价(自动计算) */ + private BigDecimal totalPrice; + + /** 总体重(按体重时输入) */ + private BigDecimal totalWeight; + + /** 羊舍ID(当时销售的羊舍) */ + private Long sheepfoldId; + + /** 客户ID(sx_customer.id) */ + private Long customerId; + + /** 销售人员ID(sys_user.id) */ + private Long salesPersonId; + + /** 技术员ID(sys_user.id) */ + private Long technicianId; + + /** 处理人ID(sys_user.id) */ + private Long handlerId; + + /** 创建人ID(sys_user.id) */ + private Long createdBy; + /** 用户ID */ private Long userId; /** 部门ID */ private Long deptId; - // 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号 - 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; + /** 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号 */ + private List bsManageTagsList; public void setId(Long id) { this.id = id; @@ -445,7 +464,6 @@ public class SxSheepSale extends BaseEntity { this.deptId = deptId; } - // 【新增】getter 和 setter 方法 public List getBsManageTagsList() { return bsManageTagsList; } @@ -518,6 +536,22 @@ public class SxSheepSale extends BaseEntity { this.sheepfoldName = sheepfoldName; } + public BigDecimal getCurrentWeight() { + return currentWeight; + } + + public void setCurrentWeight(BigDecimal currentWeight) { + this.currentWeight = currentWeight; + } + + public String getCustomerArea() { + return customerArea; + } + + public void setCustomerArea(String customerArea) { + this.customerArea = customerArea; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -559,11 +593,13 @@ public class SxSheepSale extends BaseEntity { .append("customerName", getCustomerName()) .append("customerPhone", getCustomerPhone()) .append("customerAddress", getCustomerAddress()) + .append("customerArea", getCustomerArea()) .append("salesPersonName", getSalesPersonName()) .append("technicianName", getTechnicianName()) .append("handlerName", getHandlerName()) .append("createdByName", getCreatedByName()) .append("sheepfoldName", getSheepfoldName()) + .append("currentWeight", getCurrentWeight()) .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 index 8b6788f..a619358 100644 --- 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 @@ -65,4 +65,19 @@ public interface SxSheepSaleMapper { * @return 羊只信息 (只包含视图中的字段) */ public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags); + + /** + * 根据羊舍ID查询存栏羊只耳号列表 + * @param sheepfoldId 羊舍ID + * @return 耳号列表 + */ + public List selectSheepTagsBySheepfoldId(Long sheepfoldId); + + /** + * 【新增】模糊查询羊只耳号列表(用于前端搜索补全) + * @param query 查询关键字 + * @return 耳号列表 + */ + public List searchEarNumbers(@Param("query") String query); + } \ 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 index bbdc73a..7d647e0 100644 --- 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 @@ -59,9 +59,21 @@ public interface ISxSheepSaleService { public int deleteSxSheepSaleById(Long id); /** - * 【新增】根据耳号查询羊只信息 + * 根据耳号查询羊只信息 * @param bsManageTags 耳号 * @return 羊只信息 */ public SxSheepSale selectSheepInfoByTag(String bsManageTags); + + /** + * 根据羊舍ID查询存栏羊只耳号列表 + */ + public List selectSheepTagsBySheepfoldId(Long sheepfoldId); + + /** + * 【新增】模糊查询羊只耳号列表 + * @param query 查询关键字 + * @return 耳号列表 + */ + public List searchEarNumbers(String query); } \ 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 index dc9c026..97cfaae 100644 --- 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 @@ -5,7 +5,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.zhyc.common.annotation.DataScope; // 【新增】引入数据权限注解 +import com.zhyc.common.annotation.DataScope; import com.zhyc.module.sale.mapper.SxSheepSaleMapper; import com.zhyc.module.sale.domain.SxSheepSale; import com.zhyc.module.sale.service.ISxSheepSaleService; @@ -34,7 +34,6 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService { /** * 查询羊只销售记录列表 - * 【新增】添加数据权限过滤注解 * deptAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s * userAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s * @@ -55,10 +54,10 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService { */ @Override public int insertSxSheepSale(SxSheepSale sxSheepSale) { - // 1. 业务验证 (例如:销售日期不能为空,淘汰销售必须填写疾病类型等) + // 1. 业务验证 (必填项校验、级联校验) validateSalesFields(sxSheepSale); - // 2. 自动计算逻辑 + // 2. 自动计算逻辑 (价格、体重) calculateSalesFields(sxSheepSale); // 3. 设置默认事件类型 @@ -121,21 +120,34 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService { } /** - * 【新增】根据耳号查询羊只信息 + * 根据耳号查询羊只信息 */ @Override public SxSheepSale selectSheepInfoByTag(String bsManageTags) { return sxSheepSaleMapper.selectSheepInfoByTag(bsManageTags); } + @Override + public List selectSheepTagsBySheepfoldId(Long sheepfoldId) { + return sxSheepSaleMapper.selectSheepTagsBySheepfoldId(sheepfoldId); + } + /** - * 【新增】自动计算总价、平均体重、平均单只价格 + * 【新增】实现模糊查询耳号 + */ + @Override + public List searchEarNumbers(String query) { + return sxSheepSaleMapper.searchEarNumbers(query); + } + + /** + * 自动计算总价、平均体重、平均单只价格 */ private void calculateSalesFields(SxSheepSale sxSheepSale) { String pricingMethod = sxSheepSale.getPricingMethod(); BigDecimal unitPrice = sxSheepSale.getUnitPrice(); - // 获取羊只数量 + // 获取羊只数量,默认为1防止除零 int sheepCount = 1; if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) { sheepCount = sxSheepSale.getBsManageTagsList().size(); @@ -145,6 +157,7 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService { } if ("按个体".equals(pricingMethod)) { + // 按个体计算逻辑 // 总价 = 单价 * 数量 if (unitPrice != null) { sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount))); @@ -152,43 +165,60 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService { // 平均单只价格就是单价 sxSheepSale.setAvgPricePerSheep(unitPrice); + // 按个体时,无需计算平均体重,清空相关字段避免混淆(可视需求决定是否保留) + sxSheepSale.setAvgWeight(null); + } 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) { - // 验证销售日期不能为空 + // 1. 基础必填校验 if (sxSheepSale.getSaleDate() == null) { throw new RuntimeException("销售日期不能为空!"); } + if (sxSheepSale.getTechnicianId() == null) { + throw new RuntimeException("技术员不能为空!"); + } + if (sxSheepSale.getHandlerId() == null) { + throw new RuntimeException("处理人不能为空!"); + } + if (sxSheepSale.getGroupCode() == null || sxSheepSale.getGroupCode().trim().isEmpty()) { + throw new RuntimeException("班组不能为空!"); + } + if (sxSheepSale.getPricingMethod() == null || sxSheepSale.getPricingMethod().trim().isEmpty()) { + throw new RuntimeException("计价方式不能为空!"); + } + // 2. 级联校验 String saleType = sxSheepSale.getSaleType(); - // 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型和班组不能为空 + // 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型不能为空 if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) { - if (sxSheepSale.getDiseaseType() == null) { + if (sxSheepSale.getDiseaseType() == null || sxSheepSale.getDiseaseType().trim().isEmpty()) { throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!"); } - if (sxSheepSale.getGroupCode() == null) { - throw new RuntimeException("淘汰销售或淘汰屠宰必须选择班组!"); - } } + // 如果疾病类型是"病残羊",则次要原因不能为空 if ("病残羊".equals(sxSheepSale.getDiseaseType())) { if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) { diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/controller/WorkOrderController.java b/zhyc-module/src/main/java/com/zhyc/module/work/controller/WorkOrderController.java index 37ecfab..a067c70 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/work/controller/WorkOrderController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/work/controller/WorkOrderController.java @@ -79,6 +79,8 @@ public class WorkOrderController extends BaseController @PostMapping public AjaxResult add(@RequestBody WorkOrder workOrder) { + workOrder.setDeptId(getDeptId()); //修改成你对应的实体类 + workOrder.setUserId(getUserId()); return toAjax(workOrderService.insertWorkOrder(workOrder)); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/domain/WorkOrder.java b/zhyc-module/src/main/java/com/zhyc/module/work/domain/WorkOrder.java index 1f3948c..922d0bf 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/work/domain/WorkOrder.java +++ b/zhyc-module/src/main/java/com/zhyc/module/work/domain/WorkOrder.java @@ -40,7 +40,8 @@ public class WorkOrder extends BaseEntity private Long planId; /** 业务类型:1免疫 2保健 3转群 4称重 5配种 6干奶 7淘汰 8消毒 9饲喂,必填 */ - @Excel(name = "业务类型:1免疫 2保健 3转群 4称重 5配种 6干奶 7淘汰 8消毒 9饲喂,必填") +// @Excel(name = "业务类型:1免疫 2保健 3转群 4称重 5配种 6干奶 7淘汰 8消毒 9饲喂,必填") + @Excel(name = "业务类型", readConverterExp = "1=免疫,2=保健,3=转群,4=称重,5=配种,6=干奶,7=淘汰,8=消毒,9=饲喂") private Integer bizType; private String bizTypes; private Integer [] bizTypeArray; @@ -100,13 +101,13 @@ public class WorkOrder extends BaseEntity private String toolList; /** 状态:0待派工 1已派工 2执行中 3已完成 4已取消 5异常,必填 */ - @Excel(name = "状态:0待派工 1已派工 2执行中 3已完成 4已取消 5异常,必填") + @Excel(name = "状态", readConverterExp = "0=待派工,1=已派工,2=执行中,3=已完成,4=已取消,5=异常") private Integer status; private String statuss; private Integer [] statusArray; /** 优先级:1普通 2重要 3紧急,必填 */ - @Excel(name = "优先级:1普通 2重要 3紧急,必填") + @Excel(name = "优先级", readConverterExp = "1=普通,2=重要,3=紧急") private Integer priority; private String prioritys; private Integer [] priorityArray; @@ -147,4 +148,6 @@ public class WorkOrder extends BaseEntity /** 逻辑删除:0正常 1已删除,必填 */ private Integer deleted; + private Long deptId; + private Long userId; } diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/enums/BizType.java b/zhyc-module/src/main/java/com/zhyc/module/work/enums/BizType.java new file mode 100644 index 0000000..cf1fef2 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/work/enums/BizType.java @@ -0,0 +1,79 @@ +package com.zhyc.module.work.enums; + + +/** + * 业务类型枚举 + */ +public enum BizType { + + IMMUNITY(1, "免疫"), + HEALTH_CARE(2, "保健"), + TRANSFER_GROUP(3, "转群"), + WEIGHING(4, "称重"), + BREEDING(5, "配种"), + DRY_MILK(6, "干奶"), + ELIMINATION(7, "淘汰"), + DISINFECTION(8, "消毒"), + FEEDING(9, "饲喂"); + + private final int code; + private final String desc; + + BizType(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (BizType type : values()) { + if (type.code == code) { + return type.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static BizType getByCode(Integer code) { + if (code == null) { + return null; + } + for (BizType type : values()) { + if (type.code == code) { + return type; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (BizType type : values()) { + if (type.desc.equals(desc)) { + return type.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskPriority.java b/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskPriority.java new file mode 100644 index 0000000..4c44af3 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskPriority.java @@ -0,0 +1,73 @@ +package com.zhyc.module.work.enums; + + +/** + * 任务优先级枚举 + */ +public enum TaskPriority { + + NORMAL(1, "普通"), + IMPORTANT(2, "重要"), + URGENT(3, "紧急"); + + private final int code; + private final String desc; + + TaskPriority(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (TaskPriority priority : values()) { + if (priority.code == code) { + return priority.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static TaskPriority getByCode(Integer code) { + if (code == null) { + return null; + } + for (TaskPriority priority : values()) { + if (priority.code == code) { + return priority; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (TaskPriority priority : values()) { + if (priority.desc.equals(desc)) { + return priority.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskStatus.java b/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskStatus.java new file mode 100644 index 0000000..8100733 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/work/enums/TaskStatus.java @@ -0,0 +1,76 @@ +package com.zhyc.module.work.enums; + + +/** + * 任务状态枚举 + */ +public enum TaskStatus { + + PENDING(0, "待派工"), + ASSIGNED(1, "已派工"), + IN_PROGRESS(2, "执行中"), + COMPLETED(3, "已完成"), + CANCELLED(4, "已取消"), + EXCEPTION(5, "异常"); + + private final int code; + private final String desc; + + TaskStatus(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + /** + * 根据code获取描述 + */ + public static String getDescByCode(Integer code) { + if (code == null) { + return ""; + } + for (TaskStatus status : values()) { + if (status.code == code) { + return status.desc; + } + } + return ""; + } + + /** + * 根据code获取枚举 + */ + public static TaskStatus getByCode(Integer code) { + if (code == null) { + return null; + } + for (TaskStatus status : values()) { + if (status.code == code) { + return status; + } + } + return null; + } + + /** + * 根据描述获取code + */ + public static Integer getCodeByDesc(String desc) { + if (desc == null || desc.trim().isEmpty()) { + return null; + } + for (TaskStatus status : values()) { + if (status.desc.equals(desc)) { + return status.code; + } + } + return null; + } +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/work/service/impl/WorkOrderServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/work/service/impl/WorkOrderServiceImpl.java index 92303a0..3644d28 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/work/service/impl/WorkOrderServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/work/service/impl/WorkOrderServiceImpl.java @@ -1,6 +1,8 @@ package com.zhyc.module.work.service.impl; import java.util.List; + +import com.zhyc.common.annotation.DataScope; import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -40,6 +42,7 @@ public class WorkOrderServiceImpl implements IWorkOrderService * @return 派工单 */ @Override + @DataScope(deptAlias = "w" , userAlias = "w") public List selectWorkOrderList(WorkOrder workOrder) { String username = SecurityUtils.getLoginUser().getUser().getNickName(); diff --git a/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml b/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml index 93abbc6..a2660f4 100644 --- a/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml +++ b/zhyc-module/src/main/resources/mapper/base/BasSheepMapper.xml @@ -167,7 +167,6 @@ LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id s.manage_tags = #{manageTags} AND s.is_delete = 0 - ${params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml index f555fb5..e4b3b5d 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/DewormMapper.xml @@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and datetime between #{params.beginDatetime} and #{params.endDatetime} and technical = #{technical} + and bs.is_delete = #{isDelete} ${params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/biosafety/DiagnosisMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/DiagnosisMapper.xml index 242edfa..ef14557 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/DiagnosisMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/DiagnosisMapper.xml @@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and result = #{result} and treat_day = #{treatDay} and sd.sheepfold_id = #{sheepfoldId} + and sf.is_delete = #{isDelete} ${params.dataScope} ORDER BY datetime DESC diff --git a/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml index d2faf3d..cf0e788 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/HealthMapper.xml @@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and datetime between #{params.beginDatetime} and #{params.endDatetime} and technical = #{technical} + and bs.is_delete = #{isDelete} ${params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml index c06c8c6..118f84a 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/ImmunityMapper.xml @@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and datetime between #{params.beginDatetime} and #{params.endDatetime} and technical = #{technical} + and bs.is_delete = #{isDelete} ${params.dataScope} diff --git a/zhyc-module/src/main/resources/mapper/biosafety/QuarantineReportMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/QuarantineReportMapper.xml index b678dbf..8dbd878 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/QuarantineReportMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/QuarantineReportMapper.xml @@ -72,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and result = #{result} and status = #{status} and sqr.sheep_type=#{sheepType} + and sf.is_delete = #{isDelete} ${params.dataScope} ORDER BY datetime DESC diff --git a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml index 9164a74..1628620 100644 --- a/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml +++ b/zhyc-module/src/main/resources/mapper/biosafety/TreatmentMapper.xml @@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and disease_id = #{diseaseId} and status = #{status} and veterinary = #{veterinary} + and bs.is_delete = #{isDelete} ${params.dataScope} ORDER BY datetime DESC diff --git a/zhyc-module/src/main/resources/mapper/dairyProducts/NpMilkInOutStoreMapper.xml b/zhyc-module/src/main/resources/mapper/dairyProducts/NpMilkInOutStoreMapper.xml index 79dce7f..ad594ea 100644 --- a/zhyc-module/src/main/resources/mapper/dairyProducts/NpMilkInOutStoreMapper.xml +++ b/zhyc-module/src/main/resources/mapper/dairyProducts/NpMilkInOutStoreMapper.xml @@ -18,10 +18,14 @@ LEFT JOIN np_milk_feed_records fr ON fr.store_id = s.id LEFT JOIN np_milk_sale_records sr ON sr.store_id = s.id - s.datetime >= #{start} - AND s.datetime <= #{end} + + AND s.datetime >= #{queryParams.params.beginTime} + + + AND s.datetime <= #{queryParams.params.endTime} + - ${params.dataScope} + ${queryParams.params.dataScope} GROUP BY s.id ORDER BY s.datetime 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 7f0c262..c6c2fc0 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyMeasureMapper.xml @@ -30,10 +30,18 @@ - + + + + + + + + + @@ -42,47 +50,54 @@ select sm.id, - sm.sheep_id, - bs.manage_tags, - ds.id as sheepfold_id, - ds.sheepfold_name, - bsv.id as variety_id, - bsv.variety as variety_name, - '体尺测量' as event_type, - bst.name as sheep_type_name, - sm.measure_date, - bs.gender, - bs.parity, - bs.birth_weight as birth_weight, - bs.weaning_weight as weaning_weight, - sm.current_weight as current_weight, - sm.height, - sm.bust, - sm.body_length, - sm.pipe_length, - sm.chest_depth, - sm.hip_height, - sm.rump_width, - sm.rump_heignt, - sm.hip_width, - sm.hip_cross_height, - bbs.breed as breed_status_name, - bs.lactation_day as lactation_day, - bs.gestation_day as gestation_day, - case when bs.mating_date is not null - then DATEDIFF(NOW(), bs.mating_date) - else null - end as post_mating_day, - sm.comment, - sm.technician, - sm.create_by, - sm.create_time + sm.sheep_id, + sm.user_id, + sm.dept_id, + bs.manage_tags, + ds.id as sheepfold_id, + ds.sheepfold_name, + bsv.id as variety_id, + bsv.variety as variety_name, + '体尺测量' as event_type, + bst.name as sheep_type_name, + sm.measure_date, + bs.gender, + bs.parity, + bs.birth_weight as birth_weight, + bs.weaning_weight as weaning_weight, + sm.current_weight as current_weight, + sm.height, + sm.bust, + sm.body_length, + sm.pipe_length, + sm.chest_depth, + sm.hip_height, + sm.rump_width, + sm.rump_heignt, + sm.hip_width, + sm.hip_cross_height, + sm.month_age, + sm.breast_depth, + sm.breast_position, + sm.breast_length, + sm.breast_adbere, + sm.breast_spacing, + sm.breast_score, + sm.body_score, + sm.lactation_day, + sm.gestation_day, + sm.post_mating_day, + bbs.breed as breed_status_name, + sm.comment, + sm.technician, + sm.create_by, + sm.create_time from sc_body_measure sm - LEFT JOIN bas_sheep bs ON sm.sheep_id = bs.id - LEFT JOIN bas_breed_status bbs ON bs.breed_status_id = bbs.id - LEFT JOIN da_sheepfold ds ON bs.sheepfold_id = ds.id - LEFT JOIN bas_sheep_type bst ON bs.type_id = bst.id - LEFT JOIN bas_sheep_variety bsv ON bs.variety_id = bsv.id + LEFT JOIN bas_sheep bs ON sm.sheep_id = bs.id + LEFT JOIN bas_breed_status bbs ON bs.breed_status_id = bbs.id + LEFT JOIN da_sheepfold ds ON bs.sheepfold_id = ds.id + LEFT JOIN bas_sheep_type bst ON bs.type_id = bst.id + LEFT JOIN bas_sheep_variety bsv ON bs.variety_id = bsv.id @@ -146,10 +168,23 @@ current_weight, hip_width, hip_cross_height, + month_age, + breast_depth, + breast_position, + breast_length, + breast_adbere, + breast_spacing, + breast_score, + body_score, + lactation_day, + gestation_day, + post_mating_day, comment, technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -165,10 +200,23 @@ #{currentWeight}, #{hipWidth}, #{hipCrossHeight}, + #{monthAge}, + #{breastDepth}, + #{breastPosition}, + #{breastLength}, + #{breastAdbere}, + #{breastSpacing}, + #{breastScore}, + #{bodyScore}, + #{lactationDay}, + #{gestationDay}, + #{postMatingDay}, #{comment}, #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -188,6 +236,17 @@ current_weight = #{currentWeight}, hip_width = #{hipWidth}, hip_cross_height = #{hipCrossHeight}, + month_age = #{monthAge}, + breast_depth = #{breastDepth}, + breast_position = #{breastPosition}, + breast_length = #{breastLength}, + breast_adbere = #{breastAdbere}, + breast_spacing = #{breastSpacing}, + breast_score = #{breastScore}, + body_score = #{bodyScore}, + lactation_day = #{lactationDay}, + gestation_day = #{gestationDay}, + post_mating_day = #{postMatingDay}, comment = #{comment}, technician = #{technician}, create_by = #{createBy}, @@ -208,11 +267,12 @@ #{id} + diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml index 6dc816f..6500661 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBodyScoreMapper.xml @@ -24,10 +24,12 @@ select sbs.id, sbs.sheep_id, + sbs.user_id, + sbs.dept_id, bs.manage_tags, - bsv.id as varietyId, - bsv.variety as varietyName, - '体况评分' as event_type, + bsv.id as varietyId, + bsv.variety as varietyName, + '体况评分' as event_type, sbs.datetime, sbs.score, ds.sheepfold_name as sheepfoldName, @@ -62,6 +64,10 @@ and bs.is_delete = #{sc.isDelete} + + and sbs.technician like concat('%', #{sc.technician}, '%') + + ${sc.params.dataScope} ORDER BY sbs.create_time DESC @@ -82,6 +88,8 @@ technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -92,6 +100,8 @@ #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -129,6 +139,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml index b674066..44b9222 100644 --- a/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/bodyManage/ScBreastRatingMapper.xml @@ -24,11 +24,15 @@ + + select sbr.*, bs.manage_tags as manageTags, + sbr.user_id, + sbr.dept_id, bsv.id as varietyId, bsv.variety as varietyName, '乳房评分' as event_type, @@ -60,6 +64,13 @@ and bs.is_delete = #{sc.isDelete} + + and sbr.technician = #{sc.technician} + + + and sbr.score = #{sc.score} + + ${sc.params.dataScope} ORDER BY sbr.create_time DESC @@ -84,6 +95,8 @@ technician, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -98,6 +111,8 @@ #{technician}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, @@ -137,6 +152,15 @@ FROM bas_sheep bs WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 - ORDER BY bs.manage_tags LIMIT 50 + ORDER BY bs.manage_tags + + + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml index 6c0b7b9..0ca050e 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml @@ -12,6 +12,8 @@ + + @@ -25,18 +27,42 @@ + + - - + AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%') @@ -50,6 +76,7 @@ AND sas.type_id = #{typeId} + ${params.dataScope} @@ -61,12 +88,50 @@ INSERT INTO sc_add_sheep - (ear_number, sheepfold, ranch_id, father, mother, born_weight, birthday, - gender, parity, variety_id, type_id, join_date, comment, technician, - create_by, create_time) - VALUES (#{earNumber}, #{sheepfold}, #{ranchId}, #{father}, #{mother}, #{bornWeight}, - #{birthday}, #{gender}, #{parity}, #{varietyId}, #{typeId}, #{joinDate}, - #{comment}, #{technician}, #{createBy}, #{createTime}) + + ear_number, + sheepfold, + ranch_id, + father, + mother, + grandpa, + grandma, + born_weight, + birthday, + gender, + parity, + variety_id, + type_id, + join_date, + comment, + technician, + create_by, + create_time, + user_id, + dept_id, + + + #{earNumber}, + #{sheepfold}, + #{ranchId}, + #{father}, + #{mother}, + #{grandpa}, + #{grandma}, + #{bornWeight}, + #{birthday}, + #{gender}, + #{parity}, + #{varietyId}, + #{typeId}, + #{joinDate}, + #{comment}, + #{technician}, + #{createBy}, + #{createTime}, + #{userId}, + #{deptId}, + diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml index e2695b3..a574a3e 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeCommentMapper.xml @@ -21,6 +21,8 @@ select scc.id, scc.sheep_id, + scc.user_id, + scc.dept_id, bs.manage_tags as manage_tags, sf.sheepfold_name as sheepfold_name, '改备注' as event_type, @@ -43,9 +45,9 @@ bs.manage_tags like concat('%', #{tag}, '%') - - - + + + and scc.technician like concat('%', #{sc.technician}, '%') @@ -66,6 +68,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY scc.create_time DESC @@ -85,6 +88,8 @@ create_time, event_date, technician, + user_id, + dept_id, #{sheepId}, @@ -94,6 +99,8 @@ #{createTime}, #{eventDate}, #{technician}, + #{userId}, + #{deptId}, @@ -128,6 +135,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml index 39b26ef..f33c1f7 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeEarMapper.xml @@ -73,6 +73,7 @@ and bs.is_delete = 1 + ${sc.params.dataScope} ORDER BY sce.create_time DESC @@ -94,6 +95,8 @@ create_time, event_date, technician, + user_id, + dept_id, #{sheepId}, @@ -105,6 +108,8 @@ #{createTime}, #{eventDate}, #{technician}, + #{userId}, + #{deptId}, @@ -141,6 +146,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml index 9119ca8..c3b9bf4 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScChangeVarietyMapper.xml @@ -65,6 +65,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY scv.create_time DESC @@ -83,8 +84,10 @@ comment, create_by, create_time, - technician, - event_date, + technician, + event_date, + user_id, + dept_id, #{sheepId}, @@ -93,8 +96,10 @@ #{comment}, #{createBy}, #{createTime}, - #{technician}, - #{eventDate}, + #{technician}, + #{eventDate}, + #{userId}, + #{deptId}, @@ -129,6 +134,6 @@ FROM bas_sheep bs WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 - ORDER BY bs.manage_tags LIMIT 50 + ORDER BY bs.manage_tags \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml index b74eb91..03cbb40 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScTransGroupMapper.xml @@ -18,11 +18,15 @@ + + SELECT tg.id, tg.sheep_id, + tg.user_id, + tg.dept_id, s.manage_tags AS manageTags, tg.event_type AS eventType, tg.trans_date AS transDate, @@ -38,9 +42,7 @@ tg.create_time, sf_from.sheepfold_name AS foldFromName, sf_to.sheepfold_name AS foldToName, - tg.technician, - st.id AS sheepTypeId, - st.name AS sheepTypeName + tg.technician FROM sc_trans_group tg LEFT JOIN bas_sheep s ON tg.sheep_id = s.id LEFT JOIN bas_sheep_type st ON s.type_id = st.id @@ -74,6 +76,7 @@ and s.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY tg.create_time DESC @@ -99,6 +102,8 @@ comment, create_by, create_time, + user_id, + dept_id, #{sheepId}, @@ -112,6 +117,8 @@ #{comment}, #{createBy}, #{createTime}, + #{userId}, + #{deptId}, 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 79073ae..103a98d 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 @@ -19,12 +19,16 @@ + + SELECT t.*, bv.variety AS varietyName, bs.manage_tags AS manageTags, + t.user_id, + t.dept_id, sf.sheepfold_name AS sheepfoldName, t.event_type AS eventType, t.transition_date AS transitionDate, @@ -77,6 +81,7 @@ and bs.ranch_id = #{sc.currentRanchId} + ${sc.params.dataScope} ORDER BY t.create_time DESC @@ -86,49 +91,54 @@ WHERE t.id = #{id} - - insert into sc_transition_info - - sheep_id, - variety_id, - trans_to, - trans_from, - event_type, - trans_type, - transition_date, - technician, - status, - comment, - create_by, - create_time, - - - #{sheepId}, - #{varietyId}, - #{transTo}, - #{transFrom}, - #{eventType}, - #{transType}, - #{transitionDate}, - #{technician}, - #{status}, - #{comment}, - #{createBy}, - #{createTime}, - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO sc_transition_info ( - sheep_id, variety_id, trans_to, trans_from, + sheep_id,sheepfold_id, variety_id, trans_to, trans_from, event_type,trans_type, transition_date, technician, status, comment, - create_by, create_time + create_by, create_time,user_id,dept_id ) VALUES ( - #{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType}, + #{item.sheepId},#{item.sheepfoldId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType}, #{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment}, - #{item.createBy}, now() + #{item.createBy}, now(), #{item.userId}, + #{item.deptId} ) @@ -171,6 +181,6 @@ FROM bas_sheep bs WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 - ORDER BY bs.manage_tags LIMIT 50 + ORDER BY bs.manage_tags \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml index 92dfb96..66d31e2 100644 --- a/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/other/ScCastrateMapper.xml @@ -50,7 +50,9 @@ and bs.sheepfold_id = #{sc.sheepfold} and bs.variety_id = #{sc.varietyId} - and sc.technician like concat('%', #{sc.technician}, '%') + + and sc.technician like concat('%', #{sc.technician}, '%') + and sc.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime} @@ -60,6 +62,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY sc.create_time DESC @@ -80,6 +83,8 @@ create_by, create_time, event_date, + user_id, + dept_id, #{sheepId}, @@ -90,6 +95,8 @@ #{createBy}, #{createTime}, #{eventDate}, + #{userId}, + #{deptId}, @@ -126,6 +133,5 @@ WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%') AND bs.is_delete = 0 ORDER BY bs.manage_tags - LIMIT 50 \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml b/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml index cb31739..6622a68 100644 --- a/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/other/ScFixHoofMapper.xml @@ -59,6 +59,7 @@ and bs.is_delete = #{sc.isDelete} + ${sc.params.dataScope} ORDER BY fh.create_time DESC @@ -68,26 +69,32 @@ where fh.id = #{id} - - INSERT INTO sc_fix_hoof - (sheep_id, - sheepfold, - variety_id, - comment, - technician, - event_date, - create_by, - create_time) - VALUES - (#{sheepId}, - #{sheepfold}, - #{varietyId}, - #{comment}, - #{technician}, - #{eventDate}, - #{createBy}, - #{createTime}) + + insert into sc_fix_hoof + + sheep_id, + sheepfold, + variety_id, + comment, + technician, + event_date, + create_by, + create_time, + user_id, + dept_id, + + + #{sheepId}, + #{sheepfold}, + #{varietyId}, + #{comment}, + #{technician}, + #{eventDate}, + #{createBy}, + #{createTime}, + #{userId}, + #{deptId}, + diff --git a/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml b/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml index b6f20ac..f631c68 100644 --- a/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml +++ b/zhyc-module/src/main/resources/mapper/sale/SxCustomerMapper.xml @@ -13,10 +13,14 @@ + + + + - SELECT c.id, c.name, c.phone, c.province, c.city, c.district, c.address, c.remark, c.user_id, c.dept_id + SELECT c.id, c.name, c.phone, c.province, c.city, c.district, c.address, c.remark, c.user_id, c.dept_id, c.create_by, c.create_time, c.update_by, c.update_time FROM sx_customer c @@ -24,6 +28,9 @@ AND c.name LIKE CONCAT('%', #{name}, '%') + AND c.province = #{province} + AND c.city = #{city} + AND c.district = #{district} ${params.dataScope} @@ -45,6 +52,10 @@ remark, user_id, dept_id, + create_by, + create_time, + update_by, + update_time, #{name}, @@ -56,6 +67,10 @@ #{remark}, #{userId}, #{deptId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, @@ -69,6 +84,8 @@ district = #{district}, address = #{address}, remark = #{remark}, + update_by = #{updateBy}, + update_time = #{updateTime}, WHERE id = #{id} diff --git a/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml b/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml index b312e02..b4c64a0 100644 --- a/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml +++ b/zhyc-module/src/main/resources/mapper/sale/SxSheepSaleMapper.xml @@ -38,6 +38,17 @@ + + + + + + + + + + + @@ -45,6 +56,85 @@ from sx_sheep_sale s + + + + select bs_manage_tags, @@ -57,7 +147,8 @@ post_lambing_day, lactation_day, lambing_day, - sheepfold_id + sheepfold_id, + current_weight from sheep_file @@ -66,22 +157,18 @@ where bs_manage_tags = #{bsManageTags} - + SELECT bs_manage_tags + FROM sheep_file + WHERE sheepfold_id = #{sheepfoldId} - + SELECT DISTINCT bs_manage_tags + FROM sheep_file + WHERE bs_manage_tags LIKE CONCAT(#{query}, '%') + ORDER BY bs_manage_tags + LIMIT 50 diff --git a/zhyc-module/src/main/resources/mapper/work/WorkOrderMapper.xml b/zhyc-module/src/main/resources/mapper/work/WorkOrderMapper.xml index d38b162..8ac34d7 100644 --- a/zhyc-module/src/main/resources/mapper/work/WorkOrderMapper.xml +++ b/zhyc-module/src/main/resources/mapper/work/WorkOrderMapper.xml @@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, order_no, plan_id, biz_type, title, content, department, executor_ids,executor, execute_date, execute_time, sheep_scope, location, material_list, tool_list, status, priority, issuer_id, issuer,issue_time, receiver_id, receiver,receive_time, finish_time, result, remark, create_time, update_time, deleted from work_order + select id, order_no, plan_id, biz_type, title, content, department, executor_ids,executor, execute_date, execute_time, sheep_scope, location, material_list, tool_list, status, priority, issuer_id, issuer,issue_time, receiver_id, receiver,receive_time, finish_time, result, remark, create_time, update_time, deleted from work_order w @@ -140,6 +141,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, update_time, deleted, + dept_id, + user_id, #{orderNo}, @@ -170,6 +173,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{updateTime}, #{deleted}, + #{deptId}, + #{userId},