Compare commits

...

2 Commits

Author SHA1 Message Date
2c17d04b7a Merge remote-tracking branch 'origin/main' 2026-02-03 22:15:05 +08:00
9ed2039df0 耳号验证修改批量验证 2026-02-03 22:14:57 +08:00
9 changed files with 127 additions and 31 deletions

View File

@@ -1,9 +1,7 @@
package com.zhyc.module.base.controller; package com.zhyc.module.base.controller;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
@@ -110,20 +108,61 @@ public class BasSheepController extends BaseController {
} }
/** /**
* 根据耳号查询 * 批量查询羊只耳号状态
*/ */
@GetMapping("/byManageTags/{manageTags}") @GetMapping("/byManageTags/{manageTags}")
public AjaxResult byManageTags(@PathVariable String manageTags) { public AjaxResult byManageTags(@PathVariable String manageTags) {
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim()); if (manageTags == null || manageTags.trim().isEmpty()) {
if (sheep == null) { return error("管理耳号不能为空");
return error("未找到对应的羊只");
} }
// 补品种名称 // 批量查询模式 - 使用空格或逗号分割
BasSheepVariety variety = basSheepVarietyService.selectBasSheepVarietyById(sheep.getVarietyId()); String[] tags = manageTags.split("[\\s,]+");
sheep.setVarietyName(variety == null ? "" : variety.getVariety());
return success(sheep); try {
// 过滤掉空值并去重
List<String> validTags = Arrays.stream(tags)
.map(String::trim)
.filter(tag -> !tag.isEmpty())
.distinct()
.collect(Collectors.toList());
if (validTags.isEmpty()) {
return error("有效的耳号不能为空");
}
// 查询所有存在的羊只
List<BasSheep> existingSheep = basSheepService.selectBasSheepByManageTagsList(validTags);
Set<String> existingTagSet = existingSheep.stream()
.map(BasSheep::getManageTags)
.collect(Collectors.toSet());
// 分别统计在羊群和不在羊群的耳号
List<String> inHerd = new ArrayList<>();
List<String> notInHerd = new ArrayList<>();
for (String tag : validTags) {
if (existingTagSet.contains(tag)) {
inHerd.add(tag);
} else {
notInHerd.add(tag);
}
}
Map<String, Object> result = new HashMap<>();
result.put("inHerd", inHerd);
result.put("notInHerd", notInHerd);
result.put("total", validTags.size());
result.put("inHerdCount", inHerd.size());
result.put("notInHerdCount", notInHerd.size());
result.put("sheepDetails", existingSheep);
return success(result);
} catch (Exception e) {
logger.error("批量查询羊只状态异常", e);
return error("批量查询失败:" + e.getMessage());
}
} }
/** /**

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.base.mapper;
import java.util.List; import java.util.List;
import com.zhyc.common.core.domain.BaseEntity;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -73,10 +74,10 @@ public interface BasSheepMapper
/** /**
* 模糊查询母羊耳号列表 * 模糊查询母羊耳号列表
* *
* @param query 查询关键字 * @param sheep 查询关键字
* @return 耳号列表 * @return 耳号列表
*/ */
List<String> searchEarNumbers(@Param("query") String query); List<String> searchEarNumbers(BasSheep sheep);
List<BasSheep> selectBasSheepBySheepfold(String id); List<BasSheep> selectBasSheepBySheepfold(String id);
@@ -91,4 +92,5 @@ public interface BasSheepMapper
int existsByElectronicTag(@Param("tag") String tag); int existsByElectronicTag(@Param("tag") String tag);
List<BasSheep> selectBasSheepByManageTagsList(@Param("manageTagsList") List<String> manageTagsList, @Param("sheep")BasSheep sheep);
} }

View File

@@ -71,6 +71,12 @@ public interface IBasSheepService
* 根据羊只耳号获取羊只 * 根据羊只耳号获取羊只
*/ */
BasSheep selectBasSheepByManageTags(String trim); BasSheep selectBasSheepByManageTags(String trim);
/**
* 根据管理耳号列表批量查询羊只
*/
List<BasSheep> selectBasSheepByManageTagsList(List<String> manageTagsList);
/** /**
* 根据牧场ID获取羊只列表 * 根据牧场ID获取羊只列表

View File

@@ -1,8 +1,10 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope; import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.core.domain.BaseEntity;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper; import com.zhyc.module.base.mapper.BasSheepMapper;
@@ -53,10 +55,22 @@ public class BasSheepServiceImpl implements IBasSheepService
* @return * @return
*/ */
@Override @Override
@DataScope(deptAlias = "b", userAlias = "b") @DataScope(deptAlias = "s", userAlias = "s")
public List<String> searchEarNumbers(String query) { public List<String> searchEarNumbers(String query) {
return basSheepMapper.searchEarNumbers(query); BasSheep basSheep = new BasSheep();
basSheep.setManageTags(query);
return basSheepMapper.searchEarNumbers(basSheep);
} }
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<BasSheep> selectBasSheepByManageTagsList(List<String> manageTagsList) {
if (manageTagsList == null || manageTagsList.isEmpty()) {
return new ArrayList<>();
}
return basSheepMapper.selectBasSheepByManageTagsList(manageTagsList,new BasSheep());
}
/** /**
* 新增羊只基本信息 * 新增羊只基本信息
* *

View File

@@ -42,6 +42,12 @@ public class QuarantineReport extends BaseEntity
/** 全部羊耳号列表(用于多耳号查询) */ /** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers; private List<String> allEarNumbers;
@Excel(name = "品种")
private String variety;
/** 检疫日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "检疫日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
@Excel(name = "羊只类别") @Excel(name = "羊只类别")
private String sheepType; private String sheepType;
@@ -56,10 +62,7 @@ public class QuarantineReport extends BaseEntity
private String breed; private String breed;
/** 检疫日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "检疫日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 检疫项目 */ /** 检疫项目 */
@@ -103,7 +106,17 @@ public class QuarantineReport extends BaseEntity
public void setGender(String gender) { public void setGender(String gender) {
this.gender = gender; this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(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

@@ -85,6 +85,7 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
BeanUtils.copyProperties(quarantineReport, quarantine); BeanUtils.copyProperties(quarantineReport, quarantine);
quarantine.setSheepId(sheepFile.getId()); quarantine.setSheepId(sheepFile.getId());
quarantine.setSheepNo(sheepFile.getElectronicTags()); quarantine.setSheepNo(sheepFile.getElectronicTags());
quarantine.setVariety(sheepFile.getVariety() != null ? sheepFile.getVariety() : "");
quarantine.setSheepType(sheepFile.getName()); quarantine.setSheepType(sheepFile.getName());
// 性别前端处理 // 性别前端处理

View File

@@ -152,7 +152,7 @@
SELECT DISTINCT manage_tags SELECT DISTINCT manage_tags
FROM bas_sheep b FROM bas_sheep b
<where> <where>
manage_tags LIKE CONCAT(#{query}, '%') manage_tags LIKE CONCAT(#{manageTags}, '%')
AND is_delete = 0 AND is_delete = 0
${params.dataScope} ${params.dataScope}
</where> </where>
@@ -165,8 +165,26 @@
bv.variety AS varietyName bv.variety AS varietyName
FROM bas_sheep s FROM bas_sheep s
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
WHERE s.manage_tags = #{manageTags} <where>s.manage_tags = #{manageTags}
AND s.is_delete = 0 LIMIT 1 AND s.is_delete = 0
${params.dataScope}
</where>
</select>
<select id="selectBasSheepByManageTagsList" resultMap="BasSheepResult">
SELECT s.*,
bv.variety AS varietyName
FROM bas_sheep s
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
<where>manage_tags IN
<foreach collection="manageTagsList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND s.is_delete = 0
${sheep.params.dataScope}
</where>
</select> </select>
<select id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult"> <select id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult">

View File

@@ -6,18 +6,18 @@
<resultMap type="DaRanch" id="DaRanchResult"> <resultMap type="DaRanch" id="DaRanchResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="sysRanch" column="sysRanch"/> <result property="ranch" column="ranch"/>
</resultMap> </resultMap>
<sql id="selectDaRanchVo"> <sql id="selectDaRanchVo">
select id, sysRanch select id, ranch
from da_ranch from da_ranch
</sql> </sql>
<select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult"> <select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult">
<include refid="selectDaRanchVo"/> <include refid="selectDaRanchVo"/>
<where> <where>
<if test="sysRanch != null and sysRanch != ''">and sysRanch = #{sysRanch}</if> <if test="ranch != null and ranch != ''">and ranch = #{ranch}</if>
</where> </where>
</select> </select>
@@ -29,17 +29,17 @@
<insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id">
insert into da_ranch insert into da_ranch
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sysRanch != null">sysRanch,</if> <if test="ranch != null">ranch,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sysRanch != null">#{sysRanch},</if> <if test="ranch != null">#{ranch},</if>
</trim> </trim>
</insert> </insert>
<update id="updateDaRanch" parameterType="DaRanch"> <update id="updateDaRanch" parameterType="DaRanch">
update da_ranch update da_ranch
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="sysRanch != null">sysRanch = #{sysRanch},</if> <if test="ranch != null">ranch = #{ranch},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="sheepId" column="sheep_id" /> <result property="sheepId" column="sheep_id" />
<result property="sheepNo" column="sheep_no"/> <result property="sheepNo" column="sheep_no"/>
<result property="variety" column="variety"/>
<result property="sheepType" column="sheep_type"/> <result property="sheepType" column="sheep_type"/>
<result property="gender" column="gender"/> <result property="gender" column="gender"/>
<result property="monthAge" column="month_age"/> <result property="monthAge" column="month_age"/>
@@ -30,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectQuarantineReportVo"> <sql id="selectQuarantineReportVo">
select sqr.id, sheep_type,sqr.gender,sqr.parity,sqr.breed,sqr.month_age,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status, select sqr.id, sheep_type,sqr.variety,sqr.gender,sqr.parity,sqr.breed,sqr.month_age,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status,
sqr.update_by, sqr.update_time, sqr.create_by, sqr.create_time, sqr.update_by, sqr.update_time, sqr.create_by, sqr.create_time,
sqi.name as item_name, sqi.name as item_name,
sqs.name as sample, sqs.name as sample,
@@ -98,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INSERT INTO sw_quarantine_report INSERT INTO sw_quarantine_report
( (
sheep_id, sheep_id,
variety,
sheep_type, sheep_type,
month_age, month_age,
parity, parity,
@@ -121,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
#{item.sheepId}, #{item.sheepId},
#{item.variety},
#{item.sheepType}, #{item.sheepType},
#{item.monthAge}, #{item.monthAge},
#{item.parity}, #{item.parity},