Compare commits
2 Commits
57b5415405
...
2c17d04b7a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c17d04b7a | |||
| 9ed2039df0 |
@@ -1,9 +1,7 @@
|
||||
package com.zhyc.module.base.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
@@ -110,20 +108,61 @@ public class BasSheepController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据耳号查询
|
||||
* 批量查询羊只耳号状态
|
||||
*/
|
||||
@GetMapping("/byManageTags/{manageTags}")
|
||||
public AjaxResult byManageTags(@PathVariable String manageTags) {
|
||||
BasSheep sheep = basSheepService.selectBasSheepByManageTags(manageTags.trim());
|
||||
if (sheep == null) {
|
||||
return error("未找到对应的羊只");
|
||||
if (manageTags == null || manageTags.trim().isEmpty()) {
|
||||
return error("管理耳号不能为空");
|
||||
}
|
||||
|
||||
// 补品种名称
|
||||
BasSheepVariety variety = basSheepVarietyService.selectBasSheepVarietyById(sheep.getVarietyId());
|
||||
sheep.setVarietyName(variety == null ? "" : variety.getVariety());
|
||||
// 批量查询模式 - 使用空格或逗号分割
|
||||
String[] tags = manageTags.split("[\\s,,]+");
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhyc.module.base.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -73,10 +74,10 @@ public interface BasSheepMapper
|
||||
/**
|
||||
* 模糊查询母羊耳号列表
|
||||
*
|
||||
* @param query 查询关键字
|
||||
* @param sheep 查询关键字
|
||||
* @return 耳号列表
|
||||
*/
|
||||
List<String> searchEarNumbers(@Param("query") String query);
|
||||
List<String> searchEarNumbers(BasSheep sheep);
|
||||
|
||||
|
||||
List<BasSheep> selectBasSheepBySheepfold(String id);
|
||||
@@ -91,4 +92,5 @@ public interface BasSheepMapper
|
||||
int existsByElectronicTag(@Param("tag") String tag);
|
||||
|
||||
|
||||
List<BasSheep> selectBasSheepByManageTagsList(@Param("manageTagsList") List<String> manageTagsList, @Param("sheep")BasSheep sheep);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,12 @@ public interface IBasSheepService
|
||||
* 根据羊只耳号获取羊只
|
||||
*/
|
||||
BasSheep selectBasSheepByManageTags(String trim);
|
||||
/**
|
||||
* 根据管理耳号列表批量查询羊只
|
||||
*/
|
||||
List<BasSheep> selectBasSheepByManageTagsList(List<String> manageTagsList);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据牧场ID获取羊只列表
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.zhyc.module.base.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.mapper.BasSheepMapper;
|
||||
@@ -53,10 +55,22 @@ public class BasSheepServiceImpl implements IBasSheepService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "b", userAlias = "b")
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增羊只基本信息
|
||||
*
|
||||
|
||||
@@ -42,6 +42,12 @@ public class QuarantineReport extends BaseEntity
|
||||
/** 全部羊耳号列表(用于多耳号查询) */
|
||||
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 = "羊只类别")
|
||||
private String sheepType;
|
||||
@@ -56,10 +62,7 @@ public class QuarantineReport extends BaseEntity
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 排序查询
|
||||
|
||||
@@ -85,6 +85,7 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
|
||||
BeanUtils.copyProperties(quarantineReport, quarantine);
|
||||
quarantine.setSheepId(sheepFile.getId());
|
||||
quarantine.setSheepNo(sheepFile.getElectronicTags());
|
||||
quarantine.setVariety(sheepFile.getVariety() != null ? sheepFile.getVariety() : "");
|
||||
quarantine.setSheepType(sheepFile.getName());
|
||||
|
||||
// 性别前端处理
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
SELECT DISTINCT manage_tags
|
||||
FROM bas_sheep b
|
||||
<where>
|
||||
manage_tags LIKE CONCAT(#{query}, '%')
|
||||
manage_tags LIKE CONCAT(#{manageTags}, '%')
|
||||
AND is_delete = 0
|
||||
${params.dataScope}
|
||||
</where>
|
||||
@@ -165,8 +165,26 @@
|
||||
bv.variety AS varietyName
|
||||
FROM bas_sheep s
|
||||
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
|
||||
WHERE s.manage_tags = #{manageTags}
|
||||
AND s.is_delete = 0 LIMIT 1
|
||||
<where>s.manage_tags = #{manageTags}
|
||||
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 id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult">
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
|
||||
<resultMap type="DaRanch" id="DaRanchResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="sysRanch" column="sysRanch"/>
|
||||
<result property="ranch" column="ranch"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDaRanchVo">
|
||||
select id, sysRanch
|
||||
select id, ranch
|
||||
from da_ranch
|
||||
</sql>
|
||||
|
||||
<select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult">
|
||||
<include refid="selectDaRanchVo"/>
|
||||
<where>
|
||||
<if test="sysRanch != null and sysRanch != ''">and sysRanch = #{sysRanch}</if>
|
||||
<if test="ranch != null and ranch != ''">and ranch = #{ranch}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
<insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into da_ranch
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="sysRanch != null">sysRanch,</if>
|
||||
<if test="ranch != null">ranch,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sysRanch != null">#{sysRanch},</if>
|
||||
<if test="ranch != null">#{ranch},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDaRanch" parameterType="DaRanch">
|
||||
update da_ranch
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="sysRanch != null">sysRanch = #{sysRanch},</if>
|
||||
<if test="ranch != null">ranch = #{ranch},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="id" column="id" />
|
||||
<result property="sheepId" column="sheep_id" />
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="variety" column="variety"/>
|
||||
<result property="sheepType" column="sheep_type"/>
|
||||
<result property="gender" column="gender"/>
|
||||
<result property="monthAge" column="month_age"/>
|
||||
@@ -30,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<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,
|
||||
sqi.name as item_name,
|
||||
sqs.name as sample,
|
||||
@@ -98,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
INSERT INTO sw_quarantine_report
|
||||
(
|
||||
sheep_id,
|
||||
variety,
|
||||
sheep_type,
|
||||
month_age,
|
||||
parity,
|
||||
@@ -121,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.sheepId},
|
||||
#{item.variety},
|
||||
#{item.sheepType},
|
||||
#{item.monthAge},
|
||||
#{item.parity},
|
||||
|
||||
Reference in New Issue
Block a user