繁育多耳号查询
This commit is contained in:
@@ -79,14 +79,20 @@ public class ScDryMilkController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 远程搜索耳号列表
|
* 远程搜索耳号列表
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('drymilk:drymilk:query')") // 根据实际权限修改
|
||||||
@GetMapping("/searchEarNumbers")
|
@GetMapping("/searchEarNumbers")
|
||||||
public AjaxResult searchEarNumbers(@RequestParam(value = "query", required = false) String query)
|
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||||
{
|
try {
|
||||||
if (query == null) query = "";
|
List<String> earNumbers = scDryMilkService.searchEarNumbers(query);
|
||||||
List<String> list = scDryMilkService.selectSheepEarNumberList(query);
|
return success(earNumbers);
|
||||||
return AjaxResult.success(list);
|
} catch (Exception e) {
|
||||||
|
logger.error("搜索耳号异常", e);
|
||||||
|
return error("搜索耳号失败:" + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程搜索技术员列表
|
* 远程搜索技术员列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,6 +41,20 @@ public class ScSheepDeathController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISwDiseaseService swDiseaseService;
|
private ISwDiseaseService swDiseaseService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('/sheep_death/death:query')") // 根据实际权限修改
|
||||||
|
@GetMapping("/search_ear_numbers")
|
||||||
|
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||||
|
try {
|
||||||
|
List<String> earNumbers = scSheepDeathService.searchEarNumbers(query);
|
||||||
|
return success(earNumbers);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("搜索耳号异常", e);
|
||||||
|
return error("搜索耳号失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 查询羊只死淘记录列表
|
* 查询羊只死淘记录列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,15 +36,6 @@ public class ScWeanRecordController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 【新增】模糊查询耳号列表 (用于前端下拉框远程搜索)
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:list')")
|
|
||||||
@GetMapping("/search_ear_numbers")
|
|
||||||
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
|
||||||
List<String> list = scWeanRecordService.searchEarNumbers(query);
|
|
||||||
return success(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出断奶记录列表
|
* 导出断奶记录列表
|
||||||
@@ -129,5 +120,19 @@ public class ScWeanRecordController extends BaseController {
|
|||||||
return toAjax(scWeanRecordService.deleteScWeanRecordByIds(ids));
|
return toAjax(scWeanRecordService.deleteScWeanRecordByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')") // 根据实际权限修改
|
||||||
|
@GetMapping("/search_ear_numbers")
|
||||||
|
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||||
|
try {
|
||||||
|
List<String> earNumbers = scWeanRecordService.searchEarNumbers(query);
|
||||||
|
return success(earNumbers);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("搜索耳号异常", e);
|
||||||
|
return error("搜索耳号失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,16 @@ public class ScDryMilk extends BaseEntity
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 全部羊耳号列表(用于多耳号查询) */
|
||||||
|
private List<String> allEarNumbers;
|
||||||
|
|
||||||
|
public List<String> getAllEarNumbers() {
|
||||||
|
return allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllEarNumbers(List<String> allEarNumbers) {
|
||||||
|
this.allEarNumbers = allEarNumbers;
|
||||||
|
}
|
||||||
/** 主键id */
|
/** 主键id */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class ScSheepDeath extends BaseEntity
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
/** 主键ID */
|
/** 主键ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ public class ScWeanRecord extends BaseEntity {
|
|||||||
/** 主键ID */
|
/** 主键ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/** 全部羊耳号列表(用于多耳号查询) */
|
||||||
|
private List<String> allEarNumbers;
|
||||||
|
|
||||||
|
public List<String> getAllEarNumbers() {
|
||||||
|
return allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllEarNumbers(List<String> allEarNumbers) {
|
||||||
|
this.allEarNumbers = allEarNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
/** 羊只ID */
|
/** 羊只ID */
|
||||||
@Excel(name = "羊只ID")
|
@Excel(name = "羊只ID")
|
||||||
private Long sheepId;
|
private Long sheepId;
|
||||||
@@ -51,10 +62,6 @@ public class ScWeanRecord extends BaseEntity {
|
|||||||
@Excel(name = "电子耳号")
|
@Excel(name = "电子耳号")
|
||||||
private String electronicTags;
|
private String electronicTags;
|
||||||
|
|
||||||
// --- 新增查询字段 ---
|
|
||||||
|
|
||||||
/** 多耳号查询列表 */
|
|
||||||
private List<String> allEarNumbers;
|
|
||||||
|
|
||||||
/** 是否在群 (1是 0否) */
|
/** 是否在群 (1是 0否) */
|
||||||
private String isInHerd;
|
private String isInHerd;
|
||||||
|
|||||||
@@ -69,4 +69,11 @@ public interface ScDryMilkMapper
|
|||||||
* 远程搜索技术员列表
|
* 远程搜索技术员列表
|
||||||
*/
|
*/
|
||||||
public List<String> searchTechnicianList(@Param("query") String query);
|
public List<String> searchTechnicianList(@Param("query") String query);
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
|
* @param query 查询关键字
|
||||||
|
* @return 耳号列表
|
||||||
|
*/
|
||||||
|
List<String> searchEarNumbers(@Param("query") String query);
|
||||||
}
|
}
|
||||||
@@ -85,4 +85,12 @@ public interface ScSheepDeathMapper
|
|||||||
* 远程搜索:处理人
|
* 远程搜索:处理人
|
||||||
*/
|
*/
|
||||||
public List<String> selectDistinctHandler(@Param("query") String query);
|
public List<String> selectDistinctHandler(@Param("query") String query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
|
* @param query 查询关键字
|
||||||
|
* @return 耳号列表
|
||||||
|
*/
|
||||||
|
List<String> searchEarNumbers(@Param("query") String query);
|
||||||
}
|
}
|
||||||
@@ -68,9 +68,10 @@ public interface ScWeanRecordMapper
|
|||||||
public int updateBasSheepWeaningInfo(ScWeanRecord scWeanRecord);
|
public int updateBasSheepWeaningInfo(ScWeanRecord scWeanRecord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【新增】模糊查询耳号列表 (用于前端远程搜索)
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
* @param query 查询关键字
|
* @param query 查询关键字
|
||||||
* @return 耳号列表
|
* @return 耳号列表
|
||||||
*/
|
*/
|
||||||
public List<String> searchEarNumbers(@Param("query") String query);
|
List<String> searchEarNumbers(@Param("query") String query);
|
||||||
}
|
}
|
||||||
@@ -66,4 +66,12 @@ public interface IScDryMilkService
|
|||||||
* 远程搜索技术员列表
|
* 远程搜索技术员列表
|
||||||
*/
|
*/
|
||||||
public List<String> selectTechnicianList(String query);
|
public List<String> selectTechnicianList(String query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
|
* @param query 查询关键字
|
||||||
|
* @return 耳号列表
|
||||||
|
*/
|
||||||
|
public List<String> searchEarNumbers(String query);
|
||||||
}
|
}
|
||||||
@@ -82,4 +82,12 @@ public interface IScSheepDeathService
|
|||||||
* 远程搜索:处理人
|
* 远程搜索:处理人
|
||||||
*/
|
*/
|
||||||
public List<String> selectDistinctHandler(String query);
|
public List<String> selectDistinctHandler(String query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
|
* @param query 查询关键字
|
||||||
|
* @return 耳号列表
|
||||||
|
*/
|
||||||
|
public List<String> searchEarNumbers(String query);
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,8 @@ public interface IScWeanRecordService
|
|||||||
public Long selectSheepIdByEarNumber(String earNumber);
|
public Long selectSheepIdByEarNumber(String earNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【新增】模糊查询耳号列表
|
* 模糊查询母羊耳号列表
|
||||||
|
*
|
||||||
* @param query 查询关键字
|
* @param query 查询关键字
|
||||||
* @return 耳号列表
|
* @return 耳号列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -104,4 +104,9 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
|
|||||||
public List<String> selectTechnicianList(String query) {
|
public List<String> selectTechnicianList(String query) {
|
||||||
return scDryMilkMapper.searchTechnicianList(query);
|
return scDryMilkMapper.searchTechnicianList(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> searchEarNumbers(String query) {
|
||||||
|
return scDryMilkMapper.searchEarNumbers(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,10 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
|||||||
{
|
{
|
||||||
return scSheepDeathMapper.selectSheepFileByManageTags(manageTags);
|
return scSheepDeathMapper.selectSheepFileByManageTags(manageTags);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public List<String> searchEarNumbers(String query) {
|
||||||
|
return scSheepDeathMapper.searchEarNumbers(query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -114,11 +114,6 @@ public class ScWeanRecordServiceImpl implements IScWeanRecordService
|
|||||||
return scWeanRecordMapper.selectSheepIdByEarNumber(earNumber);
|
return scWeanRecordMapper.selectSheepIdByEarNumber(earNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 【新增】模糊查询耳号列表 (用于前端远程搜索)
|
|
||||||
* @param query 查询关键字
|
|
||||||
* @return 耳号列表
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> searchEarNumbers(String query) {
|
public List<String> searchEarNumbers(String query) {
|
||||||
return scWeanRecordMapper.searchEarNumbers(query);
|
return scWeanRecordMapper.searchEarNumbers(query);
|
||||||
|
|||||||
@@ -33,6 +33,16 @@
|
|||||||
<select id="selectScDryMilkList" parameterType="ScDryMilk" resultMap="ScDryMilkResult">
|
<select id="selectScDryMilkList" parameterType="ScDryMilk" resultMap="ScDryMilkResult">
|
||||||
<include refid="selectScDryMilkVo"/>
|
<include refid="selectScDryMilkVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
<!-- 全部羊多耳号查询 -->
|
||||||
|
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||||
|
AND (
|
||||||
|
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||||
|
s.bs_manage_tags IN
|
||||||
|
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
|
#{earNumber}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
<if test="manageTagsList != null and manageTagsList.size() > 0">
|
<if test="manageTagsList != null and manageTagsList.size() > 0">
|
||||||
AND s.bs_manage_tags IN
|
AND s.bs_manage_tags IN
|
||||||
<foreach collection="manageTagsList" item="tag" open="(" separator="," close=")">
|
<foreach collection="manageTagsList" item="tag" open="(" separator="," close=")">
|
||||||
|
|||||||
@@ -39,15 +39,52 @@
|
|||||||
select d.id, d.sheep_id, d.manage_tags, d.event_type, d.death_date, d.disease_type_id, d.disease_subtype_id,
|
select d.id, d.sheep_id, d.manage_tags, d.event_type, d.death_date, d.disease_type_id, d.disease_subtype_id,
|
||||||
d.disposal_direction, d.technician, d.handler, d.work_group, d.create_by, d.create_time, d.comment,
|
d.disposal_direction, d.technician, d.handler, d.work_group, d.create_by, d.create_time, d.comment,
|
||||||
d.update_by, d.update_time, d.is_delete,
|
d.update_by, d.update_time, d.is_delete,
|
||||||
s.variety, s.name as sheep_type_name, s.gender, s.day_age, s.parity, s.sheepfold_name,
|
|
||||||
s.breed as breed_status, s.post_lambing_day, s.lactation_day, s.gestation_day
|
/* --- 关联数据获取 --- */
|
||||||
|
/* 1. 品种名称 (假设品种表是 bas_variety) */
|
||||||
|
(SELECT variety FROM bas_sheep_variety WHERE id = s.variety_id) as variety,
|
||||||
|
|
||||||
|
/* 2. 羊只类型名称 (从字典表获取) */
|
||||||
|
(SELECT dict_label FROM sys_dict_data WHERE dict_type = 'sys_sheep_type' AND dict_value = s.type_id) as sheep_type_name,
|
||||||
|
|
||||||
|
/* 3. 性别直接获取 */
|
||||||
|
s.gender,
|
||||||
|
|
||||||
|
/* 4. 计算日龄 (当前日期 - 出生日期) */
|
||||||
|
DATEDIFF(NOW(), s.birthday) as day_age,
|
||||||
|
|
||||||
|
/* 5. 胎次 */
|
||||||
|
s.parity,
|
||||||
|
|
||||||
|
/* 6. 羊舍名称 (假设羊舍表是 bas_sheepfold) */
|
||||||
|
(SELECT sheepfold_name FROM da_sheepfold WHERE id = s.sheepfold_id) as sheepfold_name,
|
||||||
|
|
||||||
|
/* 7. 繁育状态 (从字典表获取) */
|
||||||
|
(SELECT breed FROM bas_breed_status WHERE id = s.status_id) as breed,
|
||||||
|
|
||||||
|
/* 8. 其他数值字段 */
|
||||||
|
s.post_lambing_day,
|
||||||
|
s.lactation_day,
|
||||||
|
s.gestation_day
|
||||||
|
|
||||||
from sc_sheep_death d
|
from sc_sheep_death d
|
||||||
left join sheep_file s on d.manage_tags = s.bs_manage_tags
|
/* 关键修改:直接关联 bas_sheep 表,而不是视图 */
|
||||||
|
/* 同时只通过 manage_tags 关联,忽略 status_id 的限制 */
|
||||||
|
left join bas_sheep s on d.manage_tags = s.manage_tags AND s.is_delete = 0
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
|
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
|
||||||
<include refid="selectScSheepDeathVo"/>
|
<include refid="selectScSheepDeathVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||||
|
AND (
|
||||||
|
s.manage_tags IN
|
||||||
|
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
|
#{earNumber}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="sheepId != null "> and d.sheep_id = #{sheepId}</if>
|
<if test="sheepId != null "> and d.sheep_id = #{sheepId}</if>
|
||||||
|
|
||||||
<if test="manageTagsList != null and manageTagsList.size() > 0">
|
<if test="manageTagsList != null and manageTagsList.size() > 0">
|
||||||
@@ -99,16 +136,28 @@
|
|||||||
and d.work_group = #{workGroup}
|
and d.work_group = #{workGroup}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
|
<if test="variety != null and variety != ''">
|
||||||
|
AND s.variety_id IN (
|
||||||
|
SELECT id FROM bas_sheep_variety WHERE variety LIKE concat('%', #{variety}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="sheepTypeList != null and sheepTypeList.size() > 0">
|
<if test="sheepTypeList != null and sheepTypeList.size() > 0">
|
||||||
AND s.name IN
|
AND s.type_id IN (
|
||||||
|
SELECT dict_value FROM sys_dict_data
|
||||||
|
WHERE dict_type = 'sys_sheep_type'
|
||||||
|
AND dict_label IN
|
||||||
<foreach collection="sheepTypeList" item="sType" open="(" separator="," close=")">
|
<foreach collection="sheepTypeList" item="sType" open="(" separator="," close=")">
|
||||||
#{sType}
|
#{sType}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="(sheepTypeList == null or sheepTypeList.size() == 0) and sheepType != null and sheepType != ''">
|
<if test="(sheepTypeList == null or sheepTypeList.size() == 0) and sheepType != null and sheepType != ''">
|
||||||
and s.name like concat('%', #{sheepType}, '%')
|
AND s.type_id IN (
|
||||||
|
SELECT dict_value FROM sys_dict_data
|
||||||
|
WHERE dict_type = 'sys_sheep_type'
|
||||||
|
AND dict_label LIKE concat('%', #{sheepType}, '%')
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by d.create_time desc
|
order by d.create_time desc
|
||||||
|
|||||||
@@ -44,8 +44,11 @@
|
|||||||
<where>
|
<where>
|
||||||
<!-- 全部羊多耳号查询 -->
|
<!-- 全部羊多耳号查询 -->
|
||||||
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
<!-- 正确:sf.bs_manage_tags,sf是sheep_file的别名 -->
|
||||||
|
<!-- 全部羊多耳号查询 -->
|
||||||
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
|
||||||
AND (sf.bs_manage_tags IN
|
AND (
|
||||||
|
<!-- 注意:s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
|
||||||
|
sf.bs_manage_tags IN
|
||||||
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
|
||||||
#{earNumber}
|
#{earNumber}
|
||||||
</foreach>
|
</foreach>
|
||||||
@@ -94,12 +97,14 @@
|
|||||||
order by wr.create_time desc
|
order by wr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="searchEarNumbers" resultType="String">
|
<!-- 模糊查询耳号列表 -->
|
||||||
SELECT DISTINCT bs_manage_tags
|
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||||
FROM sheep_file
|
SELECT DISTINCT sf.bs_manage_tags
|
||||||
WHERE bs_manage_tags LIKE CONCAT('%', #{query}, '%')
|
FROM sheep_file sf
|
||||||
AND is_delete = 0
|
WHERE sf.bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||||
LIMIT 20
|
AND sf.is_delete = 0
|
||||||
|
ORDER BY sf.bs_manage_tags
|
||||||
|
LIMIT 50
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
|
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
|
||||||
|
|||||||
Reference in New Issue
Block a user