diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/controller/SheepFileController.java b/zhyc-module/src/main/java/com/zhyc/module/base/controller/SheepFileController.java index 6391bc2..24a0880 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/controller/SheepFileController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/controller/SheepFileController.java @@ -10,23 +10,18 @@ import com.zhyc.common.enums.BusinessType; import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.module.base.domain.SheepFile; import com.zhyc.module.base.service.ISheepFileService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import javax.servlet.http.HttpServletRequest; +import java.util.*; /** * 羊只档案Controller - * - * @author wyt + * * @author wyt * @date 2025-07-13 */ @RestController @@ -52,7 +47,7 @@ public class SheepFileController extends BaseController Integer pageSize = 10; if (queryParams != null && !queryParams.isEmpty()) { - // 提取分页参数 + // ------------------ 1. 处理分页参数 ------------------ if (queryParams.containsKey("pageNum") && queryParams.get("pageNum") != null) { try { pageNum = Integer.parseInt(queryParams.get("pageNum").toString()); @@ -60,7 +55,6 @@ public class SheepFileController extends BaseController // 使用默认值 } } else if (queryParams.containsKey("page") && queryParams.get("page") != null) { - // 如果 pageNum 不存在,则尝试使用 page try { pageNum = Integer.parseInt(queryParams.get("page").toString()); } catch (NumberFormatException e) { @@ -68,15 +62,13 @@ public class SheepFileController extends BaseController } } - if (queryParams.containsKey("pageSize") && queryParams.get("pageSize") != null) { try { pageSize = Integer.parseInt(queryParams.get("pageSize").toString()); } catch (NumberFormatException e) { // 使用默认值 } - }else if (queryParams.containsKey("limit") && queryParams.get("limit") != null) { - // 如果 pageSize 不存在,则尝试使用 limit + } else if (queryParams.containsKey("limit") && queryParams.get("limit") != null) { try { pageSize = Integer.parseInt(queryParams.get("limit").toString()); } catch (NumberFormatException e) { @@ -84,7 +76,25 @@ public class SheepFileController extends BaseController } } - // 提取常规查询参数到 SheepFile 对象 + // ------------------ 2. 核心修复:处理 List 多选参数 ------------------ + // 使用 parseList 方法兼容处理 List、Array、逗号分隔字符串 + sheepFile.setAllEarNumbers(parseList(queryParams.get("allEarNumbers"))); + sheepFile.setAllEleEarNumbers(parseList(queryParams.get("allEleEarNumbers"))); + sheepFile.setAllBreedingStatus(parseList(queryParams.get("allBreedingStatus"))); + sheepFile.setAllSheepTypes(parseList(queryParams.get("allSheepTypes"))); + + // 性别处理 (需要将 String/Integer 转为 Long) + List genderStrs = parseList(queryParams.get("allGenders")); + if (genderStrs != null && !genderStrs.isEmpty()) { + List genderLongs = new ArrayList<>(); + for (String s : genderStrs) { + Long v = convertToLong(s); + if(v != null) genderLongs.add(v); + } + sheepFile.setAllGenders(genderLongs); + } + + // ------------------ 3. 处理常规单值参数 ------------------ if (queryParams.containsKey("bsManageTags") && queryParams.get("bsManageTags") != null) { sheepFile.setBsManageTags(queryParams.get("bsManageTags").toString()); } @@ -110,23 +120,17 @@ public class SheepFileController extends BaseController sheepFile.setBreed(queryParams.get("breed").toString()); } - // 移除已经处理的参数,剩下的作为自定义筛选参数 + // ------------------ 4. 提取自定义参数 (排除已处理的键) ------------------ + // 定义需要跳过的key,防止重复处理 + Set processedKeys = new HashSet<>(Arrays.asList( + "pageNum", "pageSize", "page", "limit", + "bsManageTags", "electronicTags", "drRanch", "variety", "name", "gender", "statusId", "breed", + "allEarNumbers", "allEleEarNumbers", "allGenders", "allBreedingStatus", "allSheepTypes" + )); + for (Map.Entry entry : queryParams.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - - // 跳过常规参数和分页参数 - if ("bsManageTags".equals(key) || "electronicTags".equals(key) || - "drRanch".equals(key) || "variety".equals(key) || - "name".equals(key) || "gender".equals(key) || - "statusId".equals(key) || "breed".equals(key) || - "pageNum".equals(key) || "pageSize".equals(key)) { - continue; - } - - // 添加到自定义参数中 - if (value != null) { - customParams.put(key, value); + if (!processedKeys.contains(entry.getKey()) && entry.getValue() != null) { + customParams.put(entry.getKey(), entry.getValue()); } } } @@ -139,6 +143,41 @@ public class SheepFileController extends BaseController return getDataTable(list); } + + /** + * 辅助方法:统一解析各种格式的数组参数 + * 支持:List, String[] (数组), Object[] (数组), "A,B" (逗号分隔字符串) + */ + private List parseList(Object obj) { + if (obj == null) return null; + List result = new ArrayList<>(); + + if (obj instanceof List) { + // JSON 传来的通常是 List + for (Object o : (List) obj) { + if (o != null) result.add(o.toString()); + } + } else if (obj.getClass().isArray()) { + // 如果是数组 + if (obj instanceof Object[]) { + for (Object o : (Object[]) obj) { + if (o != null) result.add(o.toString()); + } + } else if (obj instanceof String[]) { + Collections.addAll(result, (String[]) obj); + } + } else if (obj instanceof String) { + // 如果是逗号分隔字符串 + String s = (String) obj; + if (StringUtils.isNotBlank(s)) { + String[] split = s.split(","); + Collections.addAll(result, split); + } + } + + return result.isEmpty() ? null : result; + } + /** * 转换对象为Long类型 */ @@ -186,6 +225,7 @@ public class SheepFileController extends BaseController // 使用若依框架的工具方法处理参数 switch (key) { + // --- 单值参数 --- case "bsManageTags": sheepFile.setBsManageTags(convertToString(value)); break; @@ -210,6 +250,30 @@ public class SheepFileController extends BaseController case "breed": sheepFile.setBreed(convertToString(value)); break; + + // --- 新增:处理多选数组参数 --- + // request.getParameterMap 中的值本身就是 String[],可以直接使用 + case "allEarNumbers": + sheepFile.setAllEarNumbers(new ArrayList<>(Arrays.asList(values))); + break; + case "allEleEarNumbers": + sheepFile.setAllEleEarNumbers(new ArrayList<>(Arrays.asList(values))); + break; + case "allBreedingStatus": + sheepFile.setAllBreedingStatus(new ArrayList<>(Arrays.asList(values))); + break; + case "allSheepTypes": + sheepFile.setAllSheepTypes(new ArrayList<>(Arrays.asList(values))); + break; + case "allGenders": + List genderList = new ArrayList<>(); + for(String v : values){ + Long l = Convert.toLong(v); + if(l != null) genderList.add(l); + } + sheepFile.setAllGenders(genderList); + break; + case "pageNum": case "pageSize": // 忽略分页参数 @@ -230,6 +294,14 @@ public class SheepFileController extends BaseController util.exportExcel(response, list, "羊只档案数据"); } + /** + * 新增:模糊搜索耳号接口 (用于前端下拉框远程搜索) + */ + @GetMapping("/searchEarNumbers") + public AjaxResult searchEarNumbers(@RequestParam("query") String query) + { + return success(sheepFileService.searchEarNumbers(query)); + } /** * 字符串转换工具方法 @@ -252,15 +324,14 @@ public class SheepFileController extends BaseController } /* - * 根据耳号查询是否存在羊舍 - * */ + * 根据耳号查询是否存在羊舍 + * */ @GetMapping("/byNo/{manageTags}") public AjaxResult byManageTags(@PathVariable String manageTags){ SheepFile sheep=sheepFileService.selectBasSheepByManageTags(manageTags.trim()); return success(sheep); } - @GetMapping("/stat/sheepType") public AjaxResult statSheepType() { return success(sheepFileService.countBySheepType()); @@ -289,43 +360,18 @@ public class SheepFileController extends BaseController /** * 新增API:获取字段的唯一值列表 - * - * 这个API为前端自定义筛选功能提供数据支持 - * 当用户选择某个字段进行筛选时,前端调用此接口获取该字段的所有可能值 - * - * @param fieldName 字段名(数据库列名) - * @return AjaxResult 包含字段值列表的响应结果 - * - * 接口地址:GET /sheep_file/sheep_file/field/{fieldName} - * - * 使用示例: - * 前端请求:GET /sheep_file/sheep_file/field/bs_manage_tags - * 后端返回:{ "code": 200, "msg": "操作成功", "data": ["AF00001", "AF00002", "AF00003"] } - * - * 安全说明: - * - 使用白名单机制防止SQL注入 - * - 只有预定义的字段名可以被查询 */ @GetMapping("/field/{fieldName}") public AjaxResult getFieldValues(@PathVariable String fieldName) { try { // 调用Service层获取字段唯一值 List fieldValues = sheepFileService.getFieldValues(fieldName); - - // 返回成功响应,包含字段值列表 return AjaxResult.success("获取字段值成功", fieldValues); - } catch (IllegalArgumentException e) { - // 处理字段名不合法的异常 - // 这种情况通常是因为前端传入了不在白名单中的字段名 return AjaxResult.error("请求的字段名不合法: " + e.getMessage()); - } catch (Exception e) { - // 处理其他未知异常 - // 记录日志并返回友好的错误信息 logger.error("获取字段值失败,字段名: " + fieldName, e); return AjaxResult.error("系统错误,获取字段值失败"); } } - -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/domain/SheepFile.java b/zhyc-module/src/main/java/com/zhyc/module/base/domain/SheepFile.java index 4dc4784..9966094 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/domain/SheepFile.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/domain/SheepFile.java @@ -8,11 +8,11 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; +import java.util.List; /** * 羊只档案对象 sheep_file - * - * @author wyt + * * @author wyt * @date 2025-07-13 */ @Data @@ -29,6 +29,10 @@ public class SheepFile extends BaseEntity @Excel(name = "管理耳号") private String bsManageTags; + /** ================= 新增:多选查询字段 ================= */ + /** 耳号集合(多选/模糊查询用) */ + private List allEarNumbers; + /** 牧场id */ // @Excel(name = "牧场id") private Long ranchId; @@ -49,6 +53,10 @@ public class SheepFile extends BaseEntity @Excel(name = "电子耳号") private String electronicTags; + /** ================= 新增:多选查询字段 ================= */ + /** 电子耳号集合(多选查询用) */ + private List allEleEarNumbers; + /** 品种id */ // @Excel(name = "品种id") private Long varietyId; @@ -65,14 +73,22 @@ public class SheepFile extends BaseEntity @Excel(name = "羊只类型") private String name; + /** ================= 新增:多选查询字段 ================= */ + /** 羊只类型集合(多选查询用) */ + private List allSheepTypes; + // /** 性别 */ //// @Excel(name = "性别") // private Long gender; /** 性别 - 使用字典转换 */ - @Excel(name = "性别", dictType = "sheep_gender") // 添加 dictType + @Excel(name = "性别", dictType = "sheep_gender") private Long gender; + /** ================= 新增:多选查询字段 ================= */ + /** 性别集合(多选查询用) */ + private List allGenders; + /** 出生日期 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd") @@ -103,7 +119,6 @@ public class SheepFile extends BaseEntity @Excel(name = "羊只状态", dictType = "sheep_status") private Long statusId; - /** 断奶体重 */ @Excel(name = "断奶体重") private Double weaningWeight; @@ -129,6 +144,10 @@ public class SheepFile extends BaseEntity @Excel(name = "繁殖状态") private String breed; + /** ================= 新增:多选查询字段 ================= */ + /** 繁殖状态集合(多选查询用) */ + private List allBreedingStatus; + /** 父号id */ // @Excel(name = "父号id") private Long bsFatherId; @@ -300,6 +319,4 @@ public class SheepFile extends BaseEntity @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") private Date createTime; - - -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/mapper/SheepFileMapper.java b/zhyc-module/src/main/java/com/zhyc/module/base/mapper/SheepFileMapper.java index ad8821e..909955d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/mapper/SheepFileMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/mapper/SheepFileMapper.java @@ -27,13 +27,19 @@ public interface SheepFileMapper public SheepFile selectSheepFileById(Long id); /** - * 查询羊只档案列表 + * 查询羊只档案列表 (基础查询) * * @param sheepFile 羊只档案 * @return 羊只档案集合 */ public List selectSheepFileList(SheepFile sheepFile); + /** + * 新增:模糊查询耳号列表(用于下拉框远程搜索) + * @param query 搜索关键字 + * @return 匹配的耳号列表 + */ + List searchEarNumbers(@Param("query") String query); /** * 根据管理耳号查询 @@ -43,11 +49,9 @@ public interface SheepFileMapper */ SheepFile selectSheepByManageTags(String tags); - // 在群羊只总数 Long countInGroup(); - // 羊只类别分布(按 name 分组) List> countBySheepType(); @@ -60,52 +64,34 @@ public interface SheepFileMapper // 泌乳羊胎次分布(name = '泌乳羊' 时按 parity 分组) List> countParityOfLactation(); - /** - * 新增方法:获取指定字段的唯一值列表 - * - * 这个方法用于查询数据库中某个字段的所有不重复的值 - * 主要用于前端筛选条件中的下拉选项数据 - * - * @param fieldName 字段名(数据库表中的列名) - * @return 该字段的所有唯一值列表,按字母顺序排序 - * - * 使用场景示例: - * - 用户选择"耳号"字段时,返回所有不重复的耳号 - * - 用户选择"品种"字段时,返回所有不重复的品种名称 + * 获取指定字段的唯一值列表 (配合 XML 中的 selectFieldValues) */ - List selectFieldValues(String fieldName); + List selectFieldValues(@Param("fieldName") String fieldName); /** - * 根据复杂条件查询羊只档案列表 - * - * @param params 查询参数映射 - * @param sheepFile 原有的查询条件(保持兼容) - * @return 羊只档案列表 + * 核心修复:根据复杂条件查询羊只档案列表 + * 对应 XML 中的 对应的方法 + return sheepFileMapper.selectSheepFileListByCondition(safeConditions, sheepFile); } @Override + @Transactional public int insertSheepFile(SheepFile sheepFile) { + // int rows = sheepFileMapper.insertSheepFile(sheepFile); + // if (rows > 0) { syncToBreedRamFile(sheepFile); } + // return rows; return 0; } @Override + @Transactional public int updateSheepFile(SheepFile sheepFile) { + // int rows = sheepFileMapper.updateSheepFile(sheepFile); + // if (rows > 0) { syncToBreedRamFile(sheepFile); } + // return rows; return 0; } @@ -126,12 +142,13 @@ public class SheepFileServiceImpl implements ISheepFileService { String fieldName = entry.getKey(); Object value = entry.getValue(); - // 将前端字段名转换为数据库字段名 + // 将前端字段名转换为数据库字段名 (例如: fatherManageTags -> father_manage_tags) + // 这对于 XML 中的 ${key} = #{value} 至关重要 String dbFieldName = convertToDbFieldName(fieldName); // 验证字段名是否安全 if (isValidFieldName(dbFieldName)) { - // 处理值,确保不是 Character 类型 + // 处理值 Object safeValue = value; if (value != null) { String strValue = value.toString(); @@ -140,23 +157,17 @@ public class SheepFileServiceImpl implements ISheepFileService { if (strValue.startsWith("GT:") || strValue.startsWith("LT:") || strValue.startsWith("GE:") || strValue.startsWith("LE:")) { String numPart = strValue.substring(3); - // 验证数字部分是否安全(防止 SQL 注入) + // 验证数字部分是否安全 if (isNumeric(numPart)) { safeValue = strValue; } else { - // 如果不是数字,忽略这个条件 - System.out.println("警告:范围条件的值不是数字: " + fieldName + " = " + strValue); continue; } } else { - // 其他值直接使用字符串 safeValue = strValue; } } safeParams.put(dbFieldName, safeValue); - } else { - // 记录日志 - System.out.println("警告:忽略非法字段名: " + fieldName + " -> " + dbFieldName); } } @@ -191,61 +202,17 @@ public class SheepFileServiceImpl implements ISheepFileService { * 扩展字段名白名单验证 */ private boolean isValidFieldName(String fieldName) { - // 扩展允许查询的字段白名单 + // 字段白名单 String[] allowedFields = { - "id", - "bs_manage_tags", // 管理耳号 - "electronic_tags", // 电子耳号 - "dr_ranch", // 牧场名称 - "sheepfold_name", // 羊舍名称 - "variety", // 品种 - "family", // 家系 - "name", // 羊只类型 - "gender", // 性别 - "birthday", // 出生日期 - "day_age", // 日龄 - "month_age", // 月龄 - "parity", // 胎次 - "birth_weight", // 出生体重 - "weaning_date", // 断奶日期 - "status_id", // 羊只状态 - "weaning_weight", // 断奶体重 - "current_weight", // 当前体重 - "weaning_day_age", // 断奶日龄 - "weaning_daily_gain", // 断奶日增重 - "breed", // 繁殖状态 - "father_manage_tags", // 父亲耳号 - "mother_manage_tags", // 母亲耳号 - "receptor_manage_tags", // 受体耳号 - "grandfather_manage_tags", // 祖父耳号 - "grandmother_manage_tags", // 祖母耳号 - "maternal_grandfather_manage_tags", // 外祖父耳号 - "maternal_grandmother_manage_tags", // 外祖母耳号 - "mating_date", // 配种日期 - "mating_type_id", // 配种类型 - "preg_date", // 孕检日期 - "lambing_date", // 产羔日期 - "lambing_day", // 产羔时怀孕天数 - "mating_day", // 配后天数 - "gestation_day", // 怀孕天数 - "expected_date", // 预产日期 - "post_lambing_day", // 产后天数 - "lactation_day", // 泌乳天数 - "anestrous_day", // 空怀天数 - "mating_counts", // 配种次数 - "mating_total", // 累计配种次数 - "miscarriage_counts", // 累计流产次数 - "comment", // 备注 - "controlled", // 是否性控 - "body", // 体况评分 - "breast", // 乳房评分 - "source", // 入群来源 - "source_date", // 入群日期 - "source_ranch", // 来源牧场 - "update_by", // 修改人 - "update_time", // 修改日期 - "create_by", // 创建人 - "create_time" // 创建日期 + "id", "bs_manage_tags", "electronic_tags", "dr_ranch", "sheepfold_name", "variety", "family", + "name", "gender", "birthday", "day_age", "month_age", "parity", "birth_weight", "weaning_date", + "status_id", "weaning_weight", "current_weight", "weaning_day_age", "weaning_daily_gain", "breed", + "father_manage_tags", "mother_manage_tags", "receptor_manage_tags", "grandfather_manage_tags", + "grandmother_manage_tags", "maternal_grandfather_manage_tags", "maternal_grandmother_manage_tags", + "mating_date", "mating_type_id", "preg_date", "lambing_date", "lambing_day", "mating_day", + "gestation_day", "expected_date", "post_lambing_day", "lactation_day", "anestrous_day", + "mating_counts", "mating_total", "miscarriage_counts", "comment", "controlled", "body", "breast", + "source", "source_date", "source_ranch", "update_by", "update_time", "create_by", "create_time" }; for (String allowedField : allowedFields) { @@ -257,45 +224,32 @@ public class SheepFileServiceImpl implements ISheepFileService { return false; } - @Autowired - private IBreedRamFileService breedRamFileService; // 注入种公羊服务 - - /** - * 新增羊只档案 - */ /** * 同步公羊数据到种公羊档案表 */ private void syncToBreedRamFile(SheepFile sheepFile) { try { - // 检查是否已存在 BreedRamFile existingRam = breedRamFileService.selectBreedRamFileByOrdinaryEarNumber( sheepFile.getBsManageTags() ); if (existingRam != null) { - // 已存在,更新 BreedRamFile updateRam = convertToBreedRamFile(sheepFile); updateRam.setId(existingRam.getId()); breedRamFileService.updateBreedRamFile(updateRam); } else { - // 不存在,新增 BreedRamFile newRam = convertToBreedRamFile(sheepFile); breedRamFileService.insertBreedRamFile(newRam); } } catch (Exception e) { - // 记录日志,但不影响主流 + e.printStackTrace(); } } - /** - * 将SheepFile转换为BreedRamFile - */ private BreedRamFile convertToBreedRamFile(SheepFile sheepFile) { BreedRamFile breedRamFile = new BreedRamFile(); - // 基本信息 breedRamFile.setOrdinaryEarNumber(sheepFile.getBsManageTags()); breedRamFile.setRanchId(sheepFile.getRanchId()); breedRamFile.setRanchName(sheepFile.getDrRanch()); @@ -307,15 +261,13 @@ public class SheepFileServiceImpl implements ISheepFileService { breedRamFile.setSheepCategory(sheepFile.getName()); breedRamFile.setBirthday(sheepFile.getBirthday()); - // 体重相关 - breedRamFile.setBirthWeight(BigDecimal.valueOf(sheepFile.getBirthWeight())); + if (sheepFile.getBirthWeight() != null) breedRamFile.setBirthWeight(BigDecimal.valueOf(sheepFile.getBirthWeight())); breedRamFile.setWeaningDate(sheepFile.getWeaningDate()); breedRamFile.setWeaningDayAge(sheepFile.getWeaningDayAge()); - breedRamFile.setWeaningWeight(BigDecimal.valueOf(sheepFile.getWeaningWeight())); - breedRamFile.setWeaningDailyGain(BigDecimal.valueOf(sheepFile.getWeaningDailyGain())); - breedRamFile.setCurrentWeight(BigDecimal.valueOf(sheepFile.getCurrentWeight())); + if (sheepFile.getWeaningWeight() != null) breedRamFile.setWeaningWeight(BigDecimal.valueOf(sheepFile.getWeaningWeight())); + if (sheepFile.getWeaningDailyGain() != null) breedRamFile.setWeaningDailyGain(BigDecimal.valueOf(sheepFile.getWeaningDailyGain())); + if (sheepFile.getCurrentWeight() != null) breedRamFile.setCurrentWeight(BigDecimal.valueOf(sheepFile.getCurrentWeight())); - // 家系信息 breedRamFile.setFatherNumber(sheepFile.getFatherManageTags()); breedRamFile.setMotherNumber(sheepFile.getMotherManageTags()); breedRamFile.setGrandfatherNumber(sheepFile.getGrandfatherManageTags()); @@ -323,7 +275,6 @@ public class SheepFileServiceImpl implements ISheepFileService { breedRamFile.setMaternalGrandfatherNumber(sheepFile.getMaternalGrandfatherManageTags()); breedRamFile.setMaternalGrandmotherNumber(sheepFile.getMaternalGrandmotherManageTags()); - // 审计信息 breedRamFile.setCreateBy(sheepFile.getCreateBy()); breedRamFile.setCreateTime(sheepFile.getCreateTime()); breedRamFile.setUpdateBy(sheepFile.getUpdateBy()); @@ -332,5 +283,4 @@ public class SheepFileServiceImpl implements ISheepFileService { return breedRamFile; } - -} +} \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/base/SheepFileMapper.xml b/zhyc-module/src/main/resources/mapper/base/SheepFileMapper.xml index 1d6964c..c897edb 100644 --- a/zhyc-module/src/main/resources/mapper/base/SheepFileMapper.xml +++ b/zhyc-module/src/main/resources/mapper/base/SheepFileMapper.xml @@ -1,9 +1,9 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -79,7 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + - - - - - - - - - - FROM sheep_file - - AND is_delete = 0 + AND (is_delete = 0 OR is_delete IS NULL) - - + + AND bs_manage_tags IN + + #{item} + + + + AND electronic_tags IN + + #{item} + + + + AND gender IN + + #{item} + + + + AND breed IN + + #{item} + + + + AND name IN + + #{item} + + + + AND bs_manage_tags LIKE CONCAT('%', #{sheepFile.bsManageTags}, '%') - + AND electronic_tags LIKE CONCAT('%', #{sheepFile.electronicTags}, '%') @@ -183,23 +204,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND variety LIKE CONCAT('%', #{sheepFile.variety}, '%') - + AND name LIKE CONCAT('%', #{sheepFile.name}, '%') - + AND gender = #{sheepFile.gender} AND status_id = #{sheepFile.statusId} - + AND breed LIKE CONCAT('%', #{sheepFile.breed}, '%') - - AND ${key} IS NULL @@ -207,12 +226,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND ${key} IS NOT NULL - - - - - + AND ${key} > #{value.toString().substring(3)} @@ -228,21 +243,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - + AND ${key} IN #{item} - - - - + - AND ${key} = #{value} @@ -264,23 +272,234 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY id ASC - - - - - - - - - + + + insert into sheep_file + + bs_manage_tags, + ranch_id, + dr_ranch, + sheepfold_id, + sheepfold_name, + electronic_tags, + variety_id, + variety, + family, + name, + gender, + birthday, + day_age, + month_age, + parity, + birth_weight, + weaning_date, + status_id, + weaning_weight, + current_weight, + weaning_day_age, + weaning_daily_gain, + breed_status_id, + breed, + bs_father_id, + father_manage_tags, + bs_mother_id, + mother_manage_tags, + receptor_id, + receptor_manage_tags, + father_father_id, + grandfather_manage_tags, + father_mother_id, + grandmother_manage_tags, + father_id, + maternal_grandfather_manage_tags, + mother_id, + maternal_grandmother_manage_tags, + mating_date, + mating_type_id, + preg_date, + lambing_date, + lambing_day, + mating_day, + gestation_day, + expected_date, + post_lambing_day, + lactation_day, + anestrous_day, + mating_counts, + mating_total, + miscarriage_counts, + comment, + controlled, + body, + breast, + source, + source_date, + source_ranch_id, + source_ranch, + create_by, + create_time, + update_by, + update_time, + is_delete, + + + #{bsManageTags}, + #{ranchId}, + #{drRanch}, + #{sheepfoldId}, + #{sheepfoldName}, + #{electronicTags}, + #{varietyId}, + #{variety}, + #{family}, + #{name}, + #{gender}, + #{birthday}, + #{dayAge}, + #{monthAge}, + #{parity}, + #{birthWeight}, + #{weaningDate}, + #{statusId}, + #{weaningWeight}, + #{currentWeight}, + #{weaningDayAge}, + #{weaningDailyGain}, + #{breedStatusId}, + #{breed}, + #{bsFatherId}, + #{fatherManageTags}, + #{bsMotherId}, + #{motherManageTags}, + #{receptorId}, + #{receptorManageTags}, + #{fatherFatherId}, + #{grandfatherManageTags}, + #{fatherMotherId}, + #{grandmotherManageTags}, + #{fatherId}, + #{maternalGrandfatherManageTags}, + #{motherId}, + #{maternalGrandmotherManageTags}, + #{matingDate}, + #{matingTypeId}, + #{pregDate}, + #{lambingDate}, + #{lambingDay}, + #{matingDay}, + #{gestationDay}, + #{expectedDate}, + #{postLambingDay}, + #{lactationDay}, + #{anestrousDay}, + #{matingCounts}, + #{matingTotal}, + #{miscarriageCounts}, + #{comment}, + #{controlled}, + #{body}, + #{breast}, + #{source}, + #{sourceDate}, + #{sourceRanchId}, + #{sourceRanch}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{isDelete}, + + + + + update sheep_file + + bs_manage_tags = #{bsManageTags}, + ranch_id = #{ranchId}, + dr_ranch = #{drRanch}, + sheepfold_id = #{sheepfoldId}, + sheepfold_name = #{sheepfoldName}, + electronic_tags = #{electronicTags}, + variety_id = #{varietyId}, + variety = #{variety}, + family = #{family}, + name = #{name}, + gender = #{gender}, + birthday = #{birthday}, + day_age = #{dayAge}, + month_age = #{monthAge}, + parity = #{parity}, + birth_weight = #{birthWeight}, + weaning_date = #{weaningDate}, + status_id = #{statusId}, + weaning_weight = #{weaningWeight}, + current_weight = #{currentWeight}, + weaning_day_age = #{weaningDayAge}, + weaning_daily_gain = #{weaningDailyGain}, + breed_status_id = #{breedStatusId}, + breed = #{breed}, + bs_father_id = #{bsFatherId}, + father_manage_tags = #{fatherManageTags}, + bs_mother_id = #{bsMotherId}, + mother_manage_tags = #{motherManageTags}, + receptor_id = #{receptorId}, + receptor_manage_tags = #{receptorManageTags}, + father_father_id = #{fatherFatherId}, + grandfather_manage_tags = #{grandfatherManageTags}, + father_mother_id = #{fatherMotherId}, + grandmother_manage_tags = #{grandmotherManageTags}, + father_id = #{fatherId}, + maternal_grandfather_manage_tags = #{maternalGrandfatherManageTags}, + mother_id = #{motherId}, + maternal_grandmother_manage_tags = #{maternalGrandmotherManageTags}, + mating_date = #{matingDate}, + mating_type_id = #{matingTypeId}, + preg_date = #{pregDate}, + lambing_date = #{lambingDate}, + lambing_day = #{lambingDay}, + mating_day = #{matingDay}, + gestation_day = #{gestationDay}, + expected_date = #{expectedDate}, + post_lambing_day = #{postLambingDay}, + lactation_day = #{lactationDay}, + anestrous_day = #{anestrousDay}, + mating_counts = #{matingCounts}, + mating_total = #{matingTotal}, + miscarriage_counts = #{miscarriageCounts}, + comment = #{comment}, + controlled = #{controlled}, + body = #{body}, + breast = #{breast}, + source = #{source}, + source_date = #{sourceDate}, + source_ranch_id = #{sourceRanchId}, + source_ranch = #{sourceRanch}, + update_by = #{updateBy}, + update_time = #{updateTime}, + is_delete = #{isDelete}, + + where id = #{id} + + + + update sheep_file set is_delete = 1 where id = #{id} + + + + update sheep_file set is_delete = 1 where id in + + #{id} + + + \ No newline at end of file