更新修复了产羔页面
This commit is contained in:
parent
8bc26605e0
commit
c11faeeace
@ -1,6 +1,7 @@
|
|||||||
package com.zhyc.module.produce.breed.controller;
|
package com.zhyc.module.produce.breed.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -43,6 +44,25 @@ public class ScLambingRecordController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据母羊耳号查询最新配种记录
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')")
|
||||||
|
@GetMapping("/breeding_info/{earNumber}")
|
||||||
|
public AjaxResult getBreedingInfo(@PathVariable("earNumber") String earNumber) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> breedingInfo = scLambingRecordService.getLatestBreedingByEarNumber(earNumber);
|
||||||
|
if (breedingInfo != null && !breedingInfo.isEmpty()) {
|
||||||
|
return success(breedingInfo);
|
||||||
|
} else {
|
||||||
|
return error("未找到该母羊的配种记录,请检查耳号是否正确");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询配种信息异常", e);
|
||||||
|
return error("查询配种信息失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出产羔记录列表
|
* 导出产羔记录列表
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.zhyc.module.produce.breed.mapper;
|
package com.zhyc.module.produce.breed.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
|
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产羔记录Mapper接口
|
* 产羔记录Mapper接口
|
||||||
@ -37,6 +39,14 @@ public interface ScLambingRecordMapper
|
|||||||
*/
|
*/
|
||||||
public ScLambingRecord selectScLambingRecordDetailById(Long id);
|
public ScLambingRecord selectScLambingRecordDetailById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据母羊耳号查询最新配种记录
|
||||||
|
*
|
||||||
|
* @param earNumber 母羊耳号
|
||||||
|
* @return 配种记录信息
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getLatestBreedingByEarNumber(@Param("earNumber") String earNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产羔记录
|
* 新增产羔记录
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.zhyc.module.produce.breed.service;
|
package com.zhyc.module.produce.breed.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
|
import com.zhyc.module.produce.breed.domain.ScLambingRecord;
|
||||||
import com.zhyc.module.produce.breed.domain.ScLambDetail;
|
import com.zhyc.module.produce.breed.domain.ScLambDetail;
|
||||||
|
|
||||||
@ -14,6 +15,14 @@ public interface IScLambingRecordService {
|
|||||||
*/
|
*/
|
||||||
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord);
|
public List<ScLambingRecord> selectScLambingRecordList(ScLambingRecord scLambingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据母羊耳号查询最新配种记录
|
||||||
|
*
|
||||||
|
* @param earNumber 母羊耳号
|
||||||
|
* @return 配种记录信息
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getLatestBreedingByEarNumber(String earNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产羔记录(包含羔羊详情)
|
* 新增产羔记录(包含羔羊详情)
|
||||||
*/
|
*/
|
||||||
|
@ -2,6 +2,7 @@ package com.zhyc.module.produce.breed.service.impl;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -31,6 +32,14 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService {
|
|||||||
return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord);
|
return scLambingRecordMapper.selectScLambingRecordList(scLambingRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据母羊耳号查询最新配种记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getLatestBreedingByEarNumber(String earNumber) {
|
||||||
|
return scLambingRecordMapper.getLatestBreedingByEarNumber(earNumber);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产羔记录(包含羔羊详情)
|
* 新增产羔记录(包含羔羊详情)
|
||||||
*/
|
*/
|
||||||
@ -70,11 +79,6 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证和转换羔羊详情
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* 验证和转换羔羊详情
|
* 验证和转换羔羊详情
|
||||||
*/
|
*/
|
||||||
@ -84,7 +88,7 @@ public class ScLambingRecordServiceImpl implements IScLambingRecordService {
|
|||||||
throw new RuntimeException("羔羊耳号不能为空");
|
throw new RuntimeException("羔羊耳号不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lambDetail.getGender() == null) { // 改为检查Integer类型
|
if (lambDetail.getGender() == null) {
|
||||||
throw new RuntimeException("羔羊性别不能为空");
|
throw new RuntimeException("羔羊性别不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<result property="score" column="score" />
|
<result property="score" column="score" />
|
||||||
<result property="comment" column="comment" />
|
<result property="comment" column="comment" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
|
<!-- 修复:数据库字段是create_tme,不是create_time -->
|
||||||
<result property="createTime" column="create_tme" />
|
<result property="createTime" column="create_tme" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -66,42 +67,47 @@
|
|||||||
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
|
lr.id, lr.sheep_id, lr.parity, lr.lambs_born, lr.survival,
|
||||||
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
lr.technician, lr.score, lr.comment, lr.create_by, lr.create_tme,
|
||||||
|
|
||||||
-- 从bas_sheep表获取母羊信息
|
-- 从sheep_file视图获取母羊信息
|
||||||
mother.manage_tags as female_ear_number,
|
mother.bs_manage_tags as female_ear_number,
|
||||||
mother.variety_id as female_breed,
|
mother.variety as female_breed,
|
||||||
TIMESTAMPDIFF(MONTH, mother.birthday, NOW()) as month_age,
|
mother.month_age as month_age,
|
||||||
mother.sheepfold_id as current_shed,
|
mother.sheepfold_name as current_shed,
|
||||||
mother.ranch_id as farm,
|
mother.dr_ranch as farm,
|
||||||
|
|
||||||
-- 从sc_breed_record表获取配种信息
|
-- 从sc_breed_record表获取配种信息
|
||||||
br.create_time as breeding_date,
|
br.create_time as breeding_date,
|
||||||
DATEDIFF(lr.create_tme, br.create_time) as pregnancy_days,
|
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||||
|
|
||||||
-- 从bas_sheep表获取公羊信息
|
-- 从sheep_file视图获取公羊信息
|
||||||
father.manage_tags as male_ear_number,
|
father.bs_manage_tags as male_ear_number,
|
||||||
father.variety_id as male_breed,
|
father.variety as male_breed,
|
||||||
|
|
||||||
-- 统计羔羊信息(从bas_sheep表统计,根据母羊ID)
|
-- 统计羔羊信息(从sc_lamb_detail表统计)
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.is_delete = 0) as male_count,
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1) as male_count,
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.is_delete = 0) as female_count,
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0) as female_count,
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_male_count,
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 1) as retained_male_count,
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id = 1 AND lamb.is_delete = 0) as retained_female_count,
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 1) as retained_female_count,
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 1 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_male_count,
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 1 AND sld.is_retained = 0) as unretained_male_count,
|
||||||
(SELECT COUNT(*) FROM bas_sheep lamb WHERE lamb.mother_id = lr.sheep_id AND lamb.gender = 0 AND lamb.status_id != 1 AND lamb.is_delete = 0) as unretained_female_count
|
(SELECT COUNT(*) FROM sc_lamb_detail sld WHERE sld.lambing_record_id = lr.id AND sld.gender = 0 AND sld.is_retained = 0) as unretained_female_count
|
||||||
|
|
||||||
FROM sc_lambing_record lr
|
FROM sc_lambing_record lr
|
||||||
LEFT JOIN bas_sheep mother ON lr.sheep_id = mother.id
|
LEFT JOIN sheep_file mother ON lr.sheep_id = mother.id
|
||||||
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND lr.parity = mother.parity
|
LEFT JOIN sc_breed_record br ON lr.sheep_id = br.ewe_id AND br.create_time = (
|
||||||
LEFT JOIN bas_sheep father ON br.ram_id = father.id
|
SELECT MAX(br2.create_time)
|
||||||
|
FROM sc_breed_record br2
|
||||||
|
WHERE br2.ewe_id = lr.sheep_id
|
||||||
|
AND br2.create_time <= lr.create_tme
|
||||||
|
)
|
||||||
|
LEFT JOIN sheep_file father ON br.ram_id = father.id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 查询产羔记录列表(包含关联信息) -->
|
<!-- 查询产羔记录列表(包含关联信息) -->
|
||||||
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
<select id="selectScLambingRecordList" parameterType="ScLambingRecord" resultMap="ScLambingRecordDetailResult">
|
||||||
<include refid="selectScLambingRecordDetailVo"/>
|
<include refid="selectScLambingRecordDetailVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
<if test="femaleEarNumber != null and femaleEarNumber != ''"> and mother.bs_manage_tags LIKE CONCAT('%', #{femaleEarNumber}, '%')</if>
|
||||||
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety_id = #{femaleBreed}</if>
|
<if test="femaleBreed != null and femaleBreed != ''"> and mother.variety LIKE CONCAT('%', #{femaleBreed}, '%')</if>
|
||||||
<if test="farm != null and farm != ''"> and mother.ranch_id = #{farm}</if>
|
<if test="farm != null and farm != ''"> and mother.dr_ranch LIKE CONCAT('%', #{farm}, '%')</if>
|
||||||
<if test="sheepId != null and sheepId != ''"> and lr.sheep_id = #{sheepId}</if>
|
<if test="sheepId != null and sheepId != ''"> and lr.sheep_id = #{sheepId}</if>
|
||||||
<if test="parity != null"> and lr.parity = #{parity}</if>
|
<if test="parity != null"> and lr.parity = #{parity}</if>
|
||||||
<if test="lambsBorn != null"> and lr.lambs_born = #{lambsBorn}</if>
|
<if test="lambsBorn != null"> and lr.lambs_born = #{lambsBorn}</if>
|
||||||
@ -134,23 +140,29 @@
|
|||||||
where lr.id = #{id} and mother.is_delete = 0
|
where lr.id = #{id} and mother.is_delete = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询羔羊详情(从sc_lamb_detail表查询) -->
|
<!-- 根据母羊耳号查询最新配种记录 -->
|
||||||
<select id="selectLambDetailByLambingRecordId" parameterType="Long" resultType="ScLambDetail">
|
<select id="getLatestBreedingByEarNumber" parameterType="String" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
sf.id as sheep_id,
|
||||||
lambing_record_id as lambingRecordId,
|
sf.bs_manage_tags as female_ear_number,
|
||||||
lamb_ear_number as lambEarNumber,
|
sf.variety as female_breed,
|
||||||
lamb_breed as lambBreed,
|
sf.parity as parity,
|
||||||
gender,
|
br.ram_id as ram_id,
|
||||||
birth_weight as birthWeight,
|
ram.bs_manage_tags as male_ear_number,
|
||||||
is_retained as isRetained,
|
ram.variety as male_breed,
|
||||||
lineage,
|
br.create_time as breeding_date,
|
||||||
birthday,
|
DATEDIFF(CURDATE(), br.create_time) as pregnancy_days,
|
||||||
create_by as createBy,
|
br.technician as technician
|
||||||
create_time as createTime
|
FROM sheep_file sf
|
||||||
FROM sc_lamb_detail
|
LEFT JOIN sc_breed_record br ON sf.id = br.ewe_id
|
||||||
WHERE lambing_record_id = #{lambingRecordId}
|
LEFT JOIN sheep_file ram ON br.ram_id = ram.id
|
||||||
ORDER BY create_time ASC
|
WHERE sf.bs_manage_tags = #{earNumber}
|
||||||
|
AND sf.is_delete = 0
|
||||||
|
AND br.create_time = (
|
||||||
|
SELECT MAX(br2.create_time)
|
||||||
|
FROM sc_breed_record br2
|
||||||
|
WHERE br2.ewe_id = sf.id
|
||||||
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 新增产羔记录 -->
|
<!-- 新增产羔记录 -->
|
||||||
@ -191,8 +203,8 @@
|
|||||||
<if test="technician != null">technician = #{technician},</if>
|
<if test="technician != null">technician = #{technician},</if>
|
||||||
<if test="score != null">score = #{score},</if>
|
<if test="score != null">score = #{score},</if>
|
||||||
<if test="comment != null">comment = #{comment},</if>
|
<if test="comment != null">comment = #{comment},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="createTime != null">create_tme = #{createTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user