Merge remote-tracking branch 'origin/main'

# Conflicts:
#	zhyc-module/src/main/resources/mapper/produce/breed/ScWeanRecordMapper.xml
This commit is contained in:
zyk
2026-02-10 14:04:59 +08:00
99 changed files with 2277 additions and 502 deletions

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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()) {

View File

@@ -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<SwMedicineUsageDetails> usageDetails;

View File

@@ -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;

View File

@@ -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<SwMedicineUsageDetails> 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 = "未知";
}
}
}
}

View File

@@ -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<SwMedicineUsageDetails> 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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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 "未知";
}
}

View File

@@ -35,7 +35,14 @@ public class UserPostController {
// 获取岗位(部门)
@GetMapping("/getPost")
public AjaxResult getPost(String postName){
List<Post> list = postService.selectPostList();
List<Post> list = postService.selectPostList(postName);
return AjaxResult.success(list);
}
// 获取岗位班组
@GetMapping("/getPostTeam")
public AjaxResult getPostTeam(){
List<Post> list = postService.selectPostList("");
return AjaxResult.success(list);
}

View File

@@ -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<Post> 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<Post> selectPostList(@Param("postName") String postName);
}

View File

@@ -5,5 +5,5 @@ import com.zhyc.module.common.domain.Post;
import java.util.List;
public interface PostService {
List<Post> selectPostList();
List<Post> selectPostList(String postName);
}

View File

@@ -15,8 +15,8 @@ public class PostServiceImpl implements PostService {
PostMapper postMapper;
@Override
public List<Post> selectPostList() {
List<Post> list = postMapper.selectPostList();
public List<Post> selectPostList(String postName) {
List<Post> list = postMapper.selectPostList(postName);
return list;
}
}

View File

@@ -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<Map<String, Object>> 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<Map<String, Object>> 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<Map<String,Object>> 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<Map<String,Object>> rows = service.selectWithDynamicColumns(query);
// 解决方案:强制转换并压制警告
@SuppressWarnings("unchecked")
ExcelUtil<Map<String,Object>> util = new ExcelUtil<>((Class<Map<String,Object>>) (Class<?>) Map.class);
util.exportExcel(response, rows, "羊奶出入库数据");
}
/** 获取可选列定义(饲喂来源 + 销售去向) */
@@ -65,5 +86,4 @@ public class NpMilkInOutStoreController extends BaseController {
public AjaxResult getColumns(){
return AjaxResult.success(service.getAllColumnOptions());
}
}
}

View File

@@ -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;

View File

@@ -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<Map<String,Object>> selectWithColumns(
@Param("start") Date start, @Param("end") Date end,
@Param("queryParams") NpMilkInOutStore queryParams,
@Param("feedSources") List<String> feedSources,
@Param("saleDestinations") List<String> 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,

View File

@@ -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<Map<String,Object>> selectWithDynamicColumns(Date start, Date end);
// 修改参数为实体对象
List<Map<String,Object>> selectWithDynamicColumns(NpMilkInOutStore query);
List<Map<String,Object>> getAllColumnOptions();
List<Map<String,Object>> parseImportExcel(MultipartFile file) throws Exception;
void batchInsertFromRows(List<Map<String,Object>> rows) throws Exception;
}
}

View File

@@ -21,11 +21,12 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
private NpMilkInOutStoreMapper mapper;
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) {
@DataScope(deptAlias = "s", userAlias = "s") // 启用数据权限注解
public List<Map<String, Object>> selectWithDynamicColumns(NpMilkInOutStore query) {
List<String> feed = mapper.selectFeedSources();
List<String> 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<Map<String, Object>> parseImportExcel(MultipartFile file) throws Exception {
// 用 Apache POI 解析 Excel 第一行标题,动态映射列名跟 unit cells
@@ -61,10 +63,8 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
@Override
public void batchInsertFromRows(List<Map<String, Object>> rows) throws Exception {
// === 修改开始获取当前用户和部门ID ===
Long userId = SecurityUtils.getUserId();
Long deptId = SecurityUtils.getDeptId();
// === 修改结束 ===
for (Map<String,Object> 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);
}
}

View File

@@ -1,4 +0,0 @@
package com.zhyc.module.enums;
public enum UseType {
}

View File

@@ -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++;

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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;
}

View File

@@ -87,4 +87,14 @@ public class ScBodyScore extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -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;
}

View File

@@ -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<Map<String, Object>> selectBreedStatusList();
}

View File

@@ -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<ScBreastRating> selectScBreastRatingList(
@Param("sc") ScBreastRating sc,
@Param("manageTagsList") List<String> manageTagsList);
/**
* 查询指定日期前该羊只最新的乳房评分记录
*/
ScBreastRating selectLatestBySheepIdBeforeDate(
@Param("sheepId") Long sheepId,
@Param("measureDate") Date measureDate
);
}

View File

@@ -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<ScBodyMeasure> 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<Map<String, Object>> selectBreedStatusList() {
return scBodyMeasureMapper.selectBreedStatusList();
}
}
}

View File

@@ -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<ScBodyScore> selectScBodyScoreList(ScBodyScore scBodyScore) {
return scBodyScoreMapper.selectScBodyScoreList(scBodyScore,
scBodyScore.getManageTagsList());

View File

@@ -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<ScBreastRating> selectScBreastRatingList(ScBreastRating scBreastRating) {
return scBreastRatingMapper.selectScBreastRatingList(scBreastRating,
scBreastRating.getManageTagsList());

View File

@@ -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<ScAddSheep> util = new ExcelUtil<>(ScAddSheep.class);
List<ScAddSheep> 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);
}

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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<ScTransitionInfo> 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);

View File

@@ -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;
}

View File

@@ -82,4 +82,14 @@ public class ScChangeComment extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -101,4 +101,14 @@ public class ScChangeEar extends BaseEntity {
* 在群状态 0-全部 1-在群 2-不在群(列表查询用)
*/
private Integer inGroup;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -88,4 +88,14 @@ public class ScChangeVariety extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -112,4 +112,14 @@ public class ScTransGroup extends BaseEntity {
* 是否在群查询条件0-在群1-离群)
*/
private Integer isDelete;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -120,4 +120,14 @@ public class ScTransitionInfo extends BaseEntity {
* 当前场区名称(展示用),非数据库字段
*/
private String currentRanchName;
/**
* 用户编号(数据分离用)
*/
private Long userId;
/**
* 部门编号(数据分离用)
*/
private Long deptId;
}

View File

@@ -26,7 +26,7 @@ public interface ScChangeCommentMapper
* @param scChangeComment 改备注
* @return 改备注集合
*/
public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
// public List<ScChangeComment> selectScChangeCommentList(ScChangeComment scChangeComment);
/**
* 新增改备注

View File

@@ -35,7 +35,7 @@ public interface ScTransitionInfoMapper
* @param scTransitionInfo 转场
* @return 结果
*/
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
/**
* 修改转场

View File

@@ -20,7 +20,7 @@ public interface IScAddSheepService {
boolean deleteScAddSheepByIds(Integer[] ids);
//导入
String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName);
String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName, Long userId, Long deptId);
}

View File

@@ -33,7 +33,7 @@ public interface IScTransitionInfoService {
* @param scTransitionInfo 转场
* @return 结果
*/
public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
// public int insertScTransitionInfo(ScTransitionInfo scTransitionInfo);
/**
* 修改转场

View File

@@ -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<ScAddSheep> 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<ScAddSheep> list, boolean updateSupport, String operName) {
public String importSheep(List<ScAddSheep> 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("<br/>第").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("<br/>第").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 + "";
}
}

View File

@@ -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<ScChangeComment> 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);

View File

@@ -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<ScChangeEar> 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;
}

View File

@@ -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<ScChangeVariety> 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) {

View File

@@ -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<ScTransGroup> selectScTransGroupList(ScTransGroup scTransGroup) {
List<ScTransGroup> 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 {

View File

@@ -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<ScTransitionInfo> 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<ScTransitionInfo> 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);
}
}

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -89,4 +89,14 @@ public class ScFixHoof extends BaseEntity {
* 是否在群查询条件0-在群1-离群),非数据库字段
*/
private Integer isDelete;
/**
* 用户编号
*/
private Long userId;
/**
* 部门编号
*/
private Long deptId;
}

View File

@@ -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<ScCastrate> 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;
}

View File

@@ -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<ScFixHoof> 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);
}

View File

@@ -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}")

View File

@@ -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<String> list = sxSheepSaleService.selectSheepTagsBySheepfoldId(sheepfoldId);
return AjaxResult.success(list);
}
/**
* 【新增】搜索耳号(模糊查询)
*/
@GetMapping("/searchEarNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
List<String> earNumbers = sxSheepSaleService.searchEarNumbers(query);
return success(earNumbers);
} catch (Exception e) {
return error("搜索耳号失败:" + e.getMessage());
}
}
}

View File

@@ -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();
}
}

View File

@@ -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;
}
}

View File

@@ -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;
/** 客户IDsx_customer.id */
@Excel(name = "客户ID", readConverterExp = "s=x_customer.id")
private Long customerId;
/** 【非数据库字段】客户地址 */
@Excel(name = "详细地址")
private String customerAddress;
/** 销售人员IDsys_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;
/** 技术员IDsys_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;
/** 处理人IDsys_user.id */
@Excel(name = "处理人ID", readConverterExp = "s=ys_user.id")
private Long handlerId;
/** 次要原因 */
@Excel(name = "次要原因")
private String secondaryReason;
/** 创建人IDsys_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;
/** 客户IDsx_customer.id */
private Long customerId;
/** 销售人员IDsys_user.id */
private Long salesPersonId;
/** 技术员IDsys_user.id */
private Long technicianId;
/** 处理人IDsys_user.id */
private Long handlerId;
/** 创建人IDsys_user.id */
private Long createdBy;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
// 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号
private List<String> 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<String> 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<String> 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();
}
}

View File

@@ -65,4 +65,19 @@ public interface SxSheepSaleMapper {
* @return 羊只信息 (只包含视图中的字段)
*/
public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags);
/**
* 根据羊舍ID查询存栏羊只耳号列表
* @param sheepfoldId 羊舍ID
* @return 耳号列表
*/
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId);
/**
* 【新增】模糊查询羊只耳号列表(用于前端搜索补全)
* @param query 查询关键字
* @return 耳号列表
*/
public List<String> searchEarNumbers(@Param("query") String query);
}

View File

@@ -59,9 +59,21 @@ public interface ISxSheepSaleService {
public int deleteSxSheepSaleById(Long id);
/**
* 【新增】根据耳号查询羊只信息
* 根据耳号查询羊只信息
* @param bsManageTags 耳号
* @return 羊只信息
*/
public SxSheepSale selectSheepInfoByTag(String bsManageTags);
/**
* 根据羊舍ID查询存栏羊只耳号列表
*/
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId);
/**
* 【新增】模糊查询羊只耳号列表
* @param query 查询关键字
* @return 耳号列表
*/
public List<String> searchEarNumbers(String query);
}

View File

@@ -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<String> selectSheepTagsBySheepfoldId(Long sheepfoldId) {
return sxSheepSaleMapper.selectSheepTagsBySheepfoldId(sheepfoldId);
}
/**
* 【新增】自动计算总价、平均体重、平均单只价格
* 【新增】实现模糊查询耳号
*/
@Override
public List<String> 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()) {

View File

@@ -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));
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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<WorkOrder> selectWorkOrderList(WorkOrder workOrder)
{
String username = SecurityUtils.getLoginUser().getUser().getNickName();

View File

@@ -167,7 +167,6 @@
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
<where>s.manage_tags = #{manageTags}
AND s.is_delete = 0
${params.dataScope}
</where>
</select>

View File

@@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and datetime between #{params.beginDatetime} and #{params.endDatetime}
</if>
<if test="technical != null and technical != ''">and technical = #{technical}</if>
<if test="isDelete != null and isDelete != '' ">and bs.is_delete = #{isDelete}</if>
${params.dataScope}
</where>

View File

@@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="result != null "> and result = #{result}</if>
<if test="treatDay != null "> and treat_day = #{treatDay}</if>
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
<if test="isDelete != null and isDelete != '' ">and sf.is_delete = #{isDelete}</if>
${params.dataScope}
</where>
ORDER BY datetime DESC

View File

@@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
<if test="isDelete != null and isDelete != '' ">and bs.is_delete = #{isDelete}</if>
${params.dataScope}
</where>
<!-- 基准排序:日期永远第一序,降序 -->

View File

@@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
<if test="isDelete != null and isDelete != '' ">and bs.is_delete = #{isDelete}</if>
${params.dataScope}
</where>
<!-- 基准排序:日期永远第一序,降序 -->

View File

@@ -72,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="result != null "> and result = #{result}</if>
<if test="status != null "> and status = #{status}</if>
<if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if>
<if test="isDelete != null and isDelete != '' ">and sf.is_delete = #{isDelete}</if>
${params.dataScope}
</where>
ORDER BY datetime DESC

View File

@@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
<if test="status != null and status !=''"> and status = #{status}</if>
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
<if test="isDelete != null and isDelete != '' ">and bs.is_delete = #{isDelete}</if>
${params.dataScope}
</where>
ORDER BY datetime DESC

View File

@@ -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
<where>
<if test="start != null"> s.datetime &gt;= #{start}</if>
<if test="end != null"> AND s.datetime &lt;= #{end}</if>
<if test="queryParams.params.beginTime != null and queryParams.params.beginTime != ''">
AND s.datetime &gt;= #{queryParams.params.beginTime}
</if>
<if test="queryParams.params.endTime != null and queryParams.params.endTime != ''">
AND s.datetime &lt;= #{queryParams.params.endTime}
</if>
${params.dataScope}
${queryParams.params.dataScope}
</where>
GROUP BY s.id
ORDER BY s.datetime

View File

@@ -30,10 +30,18 @@
<result property="rumpHeignt" column="rump_heignt"/>
<result property="hipWidth" column="hip_width"/>
<result property="hipCrossHeight" column="hip_cross_height"/>
<result property="breedStatusName" column="breed_status_name"/>
<result property="monthAge" column="month_age"/>
<result property="breastDepth" column="breast_depth"/>
<result property="breastPosition" column="breast_position"/>
<result property="breastLength" column="breast_length"/>
<result property="breastAdbere" column="breast_adbere"/>
<result property="breastSpacing" column="breast_spacing"/>
<result property="breastScore" column="breast_score"/>
<result property="bodyScore" column="body_score"/>
<result property="lactationDay" column="lactation_day"/>
<result property="gestationDay" column="gestation_day"/>
<result property="postMatingDay" column="post_mating_day"/>
<result property="breedStatusName" column="breed_status_name"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
@@ -42,47 +50,54 @@
<sql id="selectScBodyMeasureVo">
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
</sql>
<select id="selectScBodyMeasureList" resultMap="ScBodyMeasureResult">
@@ -113,14 +128,21 @@
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.monthAgeStart != null">
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) >= #{sc.monthAgeStart} ]]>
and <![CDATA[ sm.month_age >= #{sc.monthAgeStart} ]]>
</if>
<if test="sc.monthAgeEnd != null">
and <![CDATA[ TIMESTAMPDIFF(MONTH, bs.birthday, CURDATE()) <= #{sc.monthAgeEnd} ]]>
and <![CDATA[ sm.month_age <= #{sc.monthAgeEnd} ]]>
</if>
<if test="sc.breedStatusName != null and sc.breedStatusName != ''">
and bbs.breed = #{sc.breedStatusName}
</if>
<if test="sc.deptId != null">
and sm.dept_id = #{sc.deptId}
</if>
<if test="sc.userId != null">
and sm.user_id = #{sc.userId}
</if>
${sc.params.dataScope}
</where>
ORDER BY sm.create_time DESC
</select>
@@ -146,10 +168,23 @@
<if test="currentWeight != null">current_weight,</if>
<if test="hipWidth != null">hip_width,</if>
<if test="hipCrossHeight != null">hip_cross_height,</if>
<if test="monthAge != null">month_age,</if>
<if test="breastDepth != null">breast_depth,</if>
<if test="breastPosition != null">breast_position,</if>
<if test="breastLength != null">breast_length,</if>
<if test="breastAdbere != null">breast_adbere,</if>
<if test="breastSpacing != null">breast_spacing,</if>
<if test="breastScore != null">breast_score,</if>
<if test="bodyScore != null">body_score,</if>
<if test="lactationDay != null">lactation_day,</if>
<if test="gestationDay != null">gestation_day,</if>
<if test="postMatingDay != null">post_mating_day,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -165,10 +200,23 @@
<if test="currentWeight != null">#{currentWeight},</if>
<if test="hipWidth != null">#{hipWidth},</if>
<if test="hipCrossHeight != null">#{hipCrossHeight},</if>
<if test="monthAge != null">#{monthAge},</if>
<if test="breastDepth != null">#{breastDepth},</if>
<if test="breastPosition != null">#{breastPosition},</if>
<if test="breastLength != null">#{breastLength},</if>
<if test="breastAdbere != null">#{breastAdbere},</if>
<if test="breastSpacing != null">#{breastSpacing},</if>
<if test="breastScore != null">#{breastScore},</if>
<if test="bodyScore != null">#{bodyScore},</if>
<if test="lactationDay != null">#{lactationDay},</if>
<if test="gestationDay != null">#{gestationDay},</if>
<if test="postMatingDay != null">#{postMatingDay},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -188,6 +236,17 @@
<if test="currentWeight != null">current_weight = #{currentWeight},</if>
<if test="hipWidth != null">hip_width = #{hipWidth},</if>
<if test="hipCrossHeight != null">hip_cross_height = #{hipCrossHeight},</if>
<if test="monthAge != null">month_age = #{monthAge},</if>
<if test="breastDepth != null">breast_depth = #{breastDepth},</if>
<if test="breastPosition != null">breast_position = #{breastPosition},</if>
<if test="breastLength != null">breast_length = #{breastLength},</if>
<if test="breastAdbere != null">breast_adbere = #{breastAdbere},</if>
<if test="breastSpacing != null">breast_spacing = #{breastSpacing},</if>
<if test="breastScore != null">breast_score = #{breastScore},</if>
<if test="bodyScore != null">body_score = #{bodyScore},</if>
<if test="lactationDay != null">lactation_day = #{lactationDay},</if>
<if test="gestationDay != null">gestation_day = #{gestationDay},</if>
<if test="postMatingDay != null">post_mating_day = #{postMatingDay},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@@ -208,11 +267,12 @@
#{id}
</foreach>
</delete>
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT bs.manage_tags
FROM bas_sheep bs
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
AND bs.is_delete = 0
ORDER BY bs.manage_tags
</select>

View File

@@ -24,10 +24,12 @@
<sql id="selectScBodyScoreVo">
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 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.technician != null and sc.technician != ''">
and sbs.technician like concat('%', #{sc.technician}, '%')
</if>
${sc.params.dataScope}
</where>
ORDER BY sbs.create_time DESC
</select>
@@ -82,6 +88,8 @@
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -92,6 +100,8 @@
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -129,6 +139,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -24,11 +24,15 @@
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScBreastRatingVo">
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 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
<if test="sc.technician != null and sc.technician != ''">
and sbr.technician = #{sc.technician}
</if>
<if test="sc.score != null">
and sbr.score = #{sc.score}
</if>
${sc.params.dataScope}
</where>
ORDER BY sbr.create_time DESC
</select>
@@ -84,6 +95,8 @@
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -98,6 +111,8 @@
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -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
</select>
<select id="selectLatestBySheepIdBeforeDate" resultMap="ScBreastRatingResult">
SELECT *
FROM sc_breast_rating
WHERE sheep_id = #{sheepId}
AND event_date &lt;= #{measureDate}
ORDER BY event_date DESC, create_time DESC LIMIT 1
</select>
</mapper>

View File

@@ -12,6 +12,8 @@
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="father" column="father"/>
<result property="mother" column="mother"/>
<result property="grandpa" column="grandpa"/>
<result property="grandma" column="grandma"/>
<result property="bornWeight" column="born_weight"/>
<result property="birthday" column="birthday"/>
<result property="gender" column="gender"/>
@@ -25,18 +27,42 @@
<result property="technician" column="technician"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
<sql id="selectScAddSheepVo">
SELECT
sas.*,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName,
st.type_name AS typeName
sas.id,
sas.ear_number,
sas.sheepfold,
sas.ranch_id,
sas.father,
sas.mother,
sas.grandpa,
sas.grandma,
sas.born_weight,
sas.birthday,
sas.gender,
sas.parity,
sas.variety_id,
sas.type_id,
sas.join_date,
sas.comment,
sas.technician,
sas.create_by,
sas.create_time,
sas.user_id,
sas.dept_id,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName,
st.type_name AS typeName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
</sql>
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
<include refid="selectScAddSheepVo"/>
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
@@ -50,6 +76,7 @@
<if test="typeId != null">
AND sas.type_id = #{typeId}
</if>
${params.dataScope}
</where>
</select>
@@ -61,12 +88,50 @@
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
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})
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="earNumber != null">ear_number,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="ranchId != null">ranch_id,</if>
<if test="father != null">father,</if>
<if test="mother != null">mother,</if>
<if test="grandpa != null">grandpa,</if>
<if test="grandma != null">grandma,</if>
<if test="bornWeight != null">born_weight,</if>
<if test="birthday != null">birthday,</if>
<if test="gender != null">gender,</if>
<if test="parity != null">parity,</if>
<if test="varietyId != null">variety_id,</if>
<if test="typeId != null">type_id,</if>
<if test="joinDate != null">join_date,</if>
<if test="comment != null">comment,</if>
<if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="earNumber != null">#{earNumber},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="ranchId != null">#{ranchId},</if>
<if test="father != null">#{father},</if>
<if test="mother != null">#{mother},</if>
<if test="grandpa != null">#{grandpa},</if>
<if test="grandma != null">#{grandma},</if>
<if test="bornWeight != null">#{bornWeight},</if>
<if test="birthday != null">#{birthday},</if>
<if test="gender != null">#{gender},</if>
<if test="parity != null">#{parity},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="joinDate != null">#{joinDate},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateScAddSheep" parameterType="ScAddSheep">

View File

@@ -21,6 +21,8 @@
<sql id="selectScChangeCommentVo">
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}, '%')
</foreach>
</if>
<!-- <if test="sc.sheepfoldId != null">-->
<!-- and bs.sheepfold_id = #{sc.sheepfoldId}-->
<!-- </if>-->
<!-- <if test="sc.sheepfoldId != null">-->
<!-- and bs.sheepfold_id = #{sc.sheepfoldId}-->
<!-- </if>-->
<if test="sc.technician != null and sc.technician != ''">
and scc.technician like concat('%', #{sc.technician}, '%')
</if>
@@ -66,6 +68,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY scc.create_time DESC
</select>
@@ -85,6 +88,8 @@
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null and sheepId != ''">#{sheepId},</if>
@@ -94,6 +99,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -128,6 +135,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -73,6 +73,7 @@
<when test="sc.inGroup == 2">and bs.is_delete = 1</when>
</choose>
</if>
${sc.params.dataScope}
</where>
ORDER BY sce.create_time DESC
</select>
@@ -94,6 +95,8 @@
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -105,6 +108,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -141,6 +146,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -65,6 +65,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY scv.create_time DESC
</select>
@@ -83,8 +84,10 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="technician != null and technician != ''">technician,</if> <!-- 新增 -->
<if test="eventDate != null">event_date,</if> <!-- 新增 -->
<if test="technician != null and technician != ''">technician,</if>
<if test="eventDate != null">event_date,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -93,8 +96,10 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="technician != null and technician != ''">#{technician},</if> <!-- 新增 -->
<if test="eventDate != null">#{eventDate},</if> <!-- 新增 -->
<if test="technician != null and technician != ''">#{technician},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -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
</select>
</mapper>

View File

@@ -18,11 +18,15 @@
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScTransGroupVo">
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 @@
<if test="sc.isDelete != null">
and s.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY tg.create_time DESC
</select>
@@ -99,6 +102,8 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -112,6 +117,8 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>

View File

@@ -19,12 +19,16 @@
<result property="comment" column="comment"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectScTransitionInfoVo">
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 @@
<if test="sc.currentRanchId != null">
and bs.ranch_id = #{sc.currentRanchId}
</if>
${sc.params.dataScope}
</where>
ORDER BY t.create_time DESC
</select>
@@ -86,49 +91,54 @@
WHERE t.id = #{id}
</select>
<insert id="insertScTransitionInfo" parameterType="ScTransitionInfo" useGeneratedKeys="true" keyProperty="id">
insert into sc_transition_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="varietyId != null">variety_id,</if>
<if test="transTo != null and transTo != ''">trans_to,</if>
<if test="transFrom != null and transFrom != ''">trans_from,</if>
<if test="eventType != null and eventType != ''">event_type,</if>
<if test="transType != null">trans_type,</if>
<if test="transitionDate != null">transition_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="status != null">status,</if>
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="transTo != null and transTo != ''">#{transTo},</if>
<if test="transFrom != null and transFrom != ''">#{transFrom},</if>
<if test="eventType != null and eventType != ''">#{eventType},</if>
<if test="transType != null">#{transType},</if>
<if test="transitionDate != null">#{transitionDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="status != null">#{status},</if>
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<!-- <insert id="insertScTransitionInfo" parameterType="ScTransitionInfo" useGeneratedKeys="true" keyProperty="id">-->
<!-- insert into sc_transition_info-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="sheepId != null">sheep_id,</if>-->
<!-- <if test="varietyId != null">variety_id,</if>-->
<!-- <if test="transTo != null and transTo != ''">trans_to,</if>-->
<!-- <if test="transFrom != null and transFrom != ''">trans_from,</if>-->
<!-- <if test="eventType != null and eventType != ''">event_type,</if>-->
<!-- <if test="transType != null">trans_type,</if>-->
<!-- <if test="transitionDate != null">transition_date,</if>-->
<!-- <if test="technician != null and technician != ''">technician,</if>-->
<!-- <if test="status != null">status,</if>-->
<!-- <if test="comment != null">comment,</if>-->
<!-- <if test="createBy != null">create_by,</if>-->
<!-- <if test="createTime != null">create_time,</if>-->
<!-- <if test="userId != null">user_id,</if>-->
<!-- <if test="deptId != null">dept_id,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="sheepId != null">#{sheepId},</if>-->
<!-- <if test="varietyId != null">#{varietyId},</if>-->
<!-- <if test="transTo != null and transTo != ''">#{transTo},</if>-->
<!-- <if test="transFrom != null and transFrom != ''">#{transFrom},</if>-->
<!-- <if test="eventType != null and eventType != ''">#{eventType},</if>-->
<!-- <if test="transType != null">#{transType},</if>-->
<!-- <if test="transitionDate != null">#{transitionDate},</if>-->
<!-- <if test="technician != null and technician != ''">#{technician},</if>-->
<!-- <if test="status != null">#{status},</if>-->
<!-- <if test="comment != null">#{comment},</if>-->
<!-- <if test="createBy != null">#{createBy},</if>-->
<!-- <if test="createTime != null">#{createTime},</if>-->
<!-- <if test="userId != null">#{userId},</if>-->
<!-- <if test="deptId != null">#{deptId},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<insert id="insertScTransitionInfoBatch">
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
<foreach collection="list" item="item" separator=",">
(
#{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}
)
</foreach>
</insert>
@@ -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
</select>
</mapper>

View File

@@ -50,7 +50,9 @@
</if>
<if test="sc.sheepfold != null">and bs.sheepfold_id = #{sc.sheepfold}</if>
<if test="sc.varietyId != null">and bs.variety_id = #{sc.varietyId}</if>
<if test="sc.technician != null and sc.technician != ''">and sc.technician like concat('%', #{sc.technician}, '%')</if>
<if test="sc.technician != null and sc.technician != ''">
and sc.technician like concat('%', #{sc.technician}, '%')
</if>
<if test="sc.params != null and sc.params.beginCreateTime != null and sc.params.beginCreateTime != '' and sc.params.endCreateTime != null and sc.params.endCreateTime != ''">
and sc.create_time between #{sc.params.beginCreateTime} and #{sc.params.endCreateTime}
</if>
@@ -60,6 +62,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY sc.create_time DESC
</select>
@@ -80,6 +83,8 @@
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="eventDate != null">event_date,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
@@ -90,6 +95,8 @@
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="eventDate != null">#{eventDate},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -126,6 +133,5 @@
WHERE bs.manage_tags LIKE CONCAT('%', #{query}, '%')
AND bs.is_delete = 0
ORDER BY bs.manage_tags
LIMIT 50
</select>
</mapper>

View File

@@ -59,6 +59,7 @@
<if test="sc.isDelete != null">
and bs.is_delete = #{sc.isDelete}
</if>
${sc.params.dataScope}
</where>
ORDER BY fh.create_time DESC
</select>
@@ -68,26 +69,32 @@
where fh.id = #{id}
</select>
<insert id="insertScFixHoof" parameterType="ScFixHoof"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_fix_hoof
(sheep_id,
sheepfold,
variety_id,
<if test="comment != null">comment,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="eventDate != null and eventDate != ''">event_date,</if>
create_by,
create_time)
VALUES
(#{sheepId},
#{sheepfold},
<if test="varietyId != null">#{varietyId},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="eventDate != null and eventDate != ''">#{eventDate},</if>
#{createBy},
#{createTime})
<insert id="insertScFixHoof" parameterType="ScFixHoof" useGeneratedKeys="true" keyProperty="id">
insert into sc_fix_hoof
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="sheepfold != null">sheepfold,</if>
<if test="varietyId != null">variety_id,</if>
<if test="comment != null">comment,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="eventDate != null and eventDate != ''">event_date,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="sheepfold != null">#{sheepfold},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="comment != null">#{comment},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="eventDate != null and eventDate != ''">#{eventDate},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateScFixHoof" parameterType="ScFixHoof">

View File

@@ -13,10 +13,14 @@
<result property="remark" column="remark"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectSxCustomerVo">
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
</sql>
@@ -24,6 +28,9 @@
<include refid="selectSxCustomerVo"/>
<where>
<if test="name != null and name != ''"> AND c.name LIKE CONCAT('%', #{name}, '%')</if>
<if test="province != null and province != ''"> AND c.province = #{province}</if>
<if test="city != null and city != ''"> AND c.city = #{city}</if>
<if test="district != null and district != ''"> AND c.district = #{district}</if>
${params.dataScope}
</where>
</select>
@@ -45,6 +52,10 @@
<if test="remark != null">remark,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
@@ -56,6 +67,10 @@
<if test="remark != null">#{remark},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
@@ -69,6 +84,8 @@
<if test="district != null">district = #{district},</if>
<if test="address != null">address = #{address},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
WHERE id = #{id}
</update>

View File

@@ -38,6 +38,17 @@
<result property="remark" column="remark" />
<result property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
<result property="customerName" column="customer_name" />
<result property="customerPhone" column="customer_phone" />
<result property="customerAddress" column="customer_address" />
<result property="customerArea" column="customer_area" />
<result property="salesPersonName" column="sales_person_name" />
<result property="technicianName" column="technician_name" />
<result property="handlerName" column="handler_name" />
<result property="createdByName" column="created_by_name" />
<result property="sheepfoldName" column="sheepfold_name" />
<result property="currentWeight" column="current_weight" />
</resultMap>
<sql id="selectSxSheepSaleVo">
@@ -45,6 +56,85 @@
from sx_sheep_sale s
</sql>
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult">
SELECT
s.*,
c.name AS customer_name,
c.phone AS customer_phone,
c.address AS customer_address,
CONCAT(IFNULL(c.province,''), IFNULL(c.city,''), IFNULL(c.district,'')) AS customer_area,
u_sale.nick_name AS sales_person_name,
u_tech.nick_name AS technician_name,
u_hand.nick_name AS handler_name,
u_create.nick_name AS created_by_name,
sf.sheepfold_name AS sheepfold_name
FROM sx_sheep_sale s
LEFT JOIN sx_customer c ON s.customer_id = c.id
LEFT JOIN sys_user u_sale ON s.sales_person_id = u_sale.user_id
LEFT JOIN sys_user u_tech ON s.technician_id = u_tech.user_id
LEFT JOIN sys_user u_hand ON s.handler_id = u_hand.user_id
LEFT JOIN sys_user u_create ON s.created_by = u_create.user_id
LEFT JOIN da_sheepfold sf ON s.sheepfold_id = sf.id
<where>
<if test="bsManageTagsList != null and bsManageTagsList.size() > 0">
AND s.bs_manage_tags IN
<foreach collection="bsManageTagsList" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
</if>
<if test="(bsManageTagsList == null or bsManageTagsList.size() == 0) and bsManageTags != null and bsManageTags != ''">
AND s.bs_manage_tags LIKE CONCAT('%', #{bsManageTags}, '%')
</if>
<if test="sheepfoldId != null "> AND s.sheepfold_id = #{sheepfoldId}</if>
<if test="variety != null and variety != ''"> AND s.variety = #{variety}</if>
<if test="sheepName != null and sheepName != ''"> AND s.sheep_name = #{sheepName}</if>
<if test="gender != null and gender != ''"> AND s.gender = #{gender}</if>
<if test="breed != null and breed != ''"> AND s.breed = #{breed}</if>
<if test="saleDate != null"> AND s.sale_date = #{saleDate}</if>
<if test="saleType != null and saleType != ''"> AND s.sale_type = #{saleType}</if>
<if test="pricingMethod != null and pricingMethod != ''"> AND s.pricing_method = #{pricingMethod}</if>
<if test="groupCode != null and groupCode != ''"> AND s.group_code = #{groupCode}</if>
<if test="approvalNo != null and approvalNo != ''">
AND s.approval_no LIKE CONCAT('%', #{approvalNo}, '%')
</if>
<if test="customerName != null and customerName != ''"> AND c.name LIKE CONCAT('%', #{customerName}, '%')</if>
<if test="salesPersonId != null"> AND s.sales_person_id = #{salesPersonId}</if>
<if test="customerArea != null and customerArea != ''">
AND (c.province LIKE CONCAT('%', #{customerArea}, '%')
OR c.city LIKE CONCAT('%', #{customerArea}, '%')
OR c.district LIKE CONCAT('%', #{customerArea}, '%'))
</if>
${params.dataScope}
</where>
ORDER BY s.sale_date DESC, s.id DESC
</select>
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult">
SELECT
s.*,
c.name AS customer_name,
c.phone AS customer_phone,
c.address AS customer_address,
CONCAT(IFNULL(c.province,''), IFNULL(c.city,''), IFNULL(c.district,'')) AS customer_area,
u_sale.nick_name AS sales_person_name,
u_tech.nick_name AS technician_name,
u_hand.nick_name AS handler_name,
u_create.nick_name AS created_by_name,
sf.sheepfold_name AS sheepfold_name
FROM sx_sheep_sale s
LEFT JOIN sx_customer c ON s.customer_id = c.id
LEFT JOIN sys_user u_sale ON s.sales_person_id = u_sale.user_id
LEFT JOIN sys_user u_tech ON s.technician_id = u_tech.user_id
LEFT JOIN sys_user u_hand ON s.handler_id = u_hand.user_id
LEFT JOIN sys_user u_create ON s.created_by = u_create.user_id
LEFT JOIN da_sheepfold sf ON s.sheepfold_id = sf.id
WHERE s.id = #{id}
</select>
<sql id="selectSheepFileVo">
select
bs_manage_tags,
@@ -57,7 +147,8 @@
post_lambing_day,
lactation_day,
lambing_day,
sheepfold_id
sheepfold_id,
current_weight
from sheep_file
</sql>
@@ -66,22 +157,18 @@
where bs_manage_tags = #{bsManageTags}
</select>
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult">
<include refid="selectSxSheepSaleVo"/>
<where>
<if test="bsManageTags != null and bsManageTags != ''"> and s.bs_manage_tags = #{bsManageTags}</if>
<if test="sheepfoldId != null "> and s.sheepfold_id = #{sheepfoldId}</if>
<if test="variety != null and variety != ''"> and s.variety = #{variety}</if>
<if test="sheepName != null and sheepName != ''"> and s.sheep_name = #{sheepName}</if>
<if test="saleDate != null"> and s.sale_date = #{saleDate}</if>
<if test="saleType != null and saleType != ''"> and s.sale_type = #{saleType}</if>
${params.dataScope}
</where>
<select id="selectSheepTagsBySheepfoldId" parameterType="Long" resultType="String">
SELECT bs_manage_tags
FROM sheep_file
WHERE sheepfold_id = #{sheepfoldId}
</select>
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult">
<include refid="selectSxSheepSaleVo"/>
where s.id = #{id}
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT bs_manage_tags
FROM sheep_file
WHERE bs_manage_tags LIKE CONCAT(#{query}, '%')
ORDER BY bs_manage_tags
LIMIT 50
</select>
<insert id="insertSxSheepSale" parameterType="SxSheepSale" useGeneratedKeys="true" keyProperty="id">

View File

@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectWorkOrderVo">
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
</sql>
<select id="selectWorkOrderList" parameterType="WorkOrder" resultMap="WorkOrderResult">
@@ -98,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and finish_time between #{beginFinishDate} and #{endFinishDate}
</if>
<if test="result != null and result != ''"> and result = #{result}</if>
${params.dataScope}
</where>
order by execute_date desc
</select>
@@ -140,6 +141,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleted != null">deleted,</if>
<if test="deptId != null">dept_id,</if>
<if test="userId != null">user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
@@ -170,6 +173,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleted != null">#{deleted},</if>
<if test="deptId != null">#{deptId},</if>
<if test="userId != null">#{userId},</if>
</trim>
</insert>