孕检记录
This commit is contained in:
parent
4f45e1fcbf
commit
1971225bc1
@ -1,10 +1,8 @@
|
|||||||
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 com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
|
||||||
import com.zhyc.module.produce.breed.service.IScPregnancyRecordService;
|
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -14,20 +12,22 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.zhyc.common.annotation.Log;
|
import com.zhyc.common.annotation.Log;
|
||||||
import com.zhyc.common.core.controller.BaseController;
|
import com.zhyc.common.core.controller.BaseController;
|
||||||
import com.zhyc.common.core.domain.AjaxResult;
|
import com.zhyc.common.core.domain.AjaxResult;
|
||||||
import com.zhyc.common.enums.BusinessType;
|
import com.zhyc.common.enums.BusinessType;
|
||||||
|
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||||
|
import com.zhyc.module.produce.breed.service.IScPregnancyRecordService;
|
||||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||||
import com.zhyc.common.core.page.TableDataInfo;
|
import com.zhyc.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 孕检记录Controller
|
* 孕检记录Controller
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author zhyc
|
||||||
* @date 2025-07-17
|
* @date 2025-01-21
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/Pregnancy_Test/Pregnancy_Test")
|
@RequestMapping("/Pregnancy_Test/Pregnancy_Test")
|
||||||
@ -98,9 +98,19 @@ public class ScPregnancyRecordController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('Pregnancy_Test:Pregnancy_Test:remove')")
|
@PreAuthorize("@ss.hasPermi('Pregnancy_Test:Pregnancy_Test:remove')")
|
||||||
@Log(title = "孕检记录", businessType = BusinessType.DELETE)
|
@Log(title = "孕检记录", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids)
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
{
|
{
|
||||||
return toAjax(scPregnancyRecordService.deleteScPregnancyRecordByIds(ids));
|
return toAjax(scPregnancyRecordService.deleteScPregnancyRecordByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据耳号获取羊只信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/getSheepByManageTags")
|
||||||
|
public AjaxResult getSheepByManageTags(@RequestParam("manageTags") String manageTags)
|
||||||
|
{
|
||||||
|
Map<String, Object> sheepInfo = scPregnancyRecordService.getSheepByManageTags(manageTags);
|
||||||
|
return success(sheepInfo);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.produce.breed.domain;
|
package com.zhyc.module.produce.breed.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
@ -10,16 +11,24 @@ import com.zhyc.common.core.domain.BaseEntity;
|
|||||||
/**
|
/**
|
||||||
* 孕检记录对象 sc_pregnancy_record
|
* 孕检记录对象 sc_pregnancy_record
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author zhyc
|
||||||
* @date 2025-07-17
|
* @date 2025-01-21
|
||||||
*/
|
*/
|
||||||
public class ScPregnancyRecord extends BaseEntity
|
public class ScPregnancyRecord extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** 主键ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/** 羊只ID */
|
||||||
|
@Excel(name = "羊只ID")
|
||||||
|
private Long sheepId;
|
||||||
|
|
||||||
|
/** 耳号 */
|
||||||
|
@Excel(name = "耳号")
|
||||||
|
private String manageTags;
|
||||||
|
|
||||||
/** 孕检日期 */
|
/** 孕检日期 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "孕检日期", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "孕检日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
@ -29,17 +38,80 @@ public class ScPregnancyRecord extends BaseEntity
|
|||||||
@Excel(name = "孕检结果")
|
@Excel(name = "孕检结果")
|
||||||
private String result;
|
private String result;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** 胎儿数量 */
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
@Excel(name = "胎儿数量")
|
||||||
private Long number;
|
private Integer fetusCount;
|
||||||
|
|
||||||
/** 技术员 */
|
/** 技术员 */
|
||||||
@Excel(name = "技术员")
|
@Excel(name = "技术员")
|
||||||
private String technician;
|
private String technician;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** 孕检方式 */
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
@Excel(name = "孕检方式")
|
||||||
private Long way;
|
private String way;
|
||||||
|
|
||||||
|
/** 备注 */
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/** 是否删除 */
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
// 关联查询字段
|
||||||
|
/** 品种 */
|
||||||
|
@Excel(name = "品种")
|
||||||
|
private String variety;
|
||||||
|
|
||||||
|
/** 月龄 */
|
||||||
|
@Excel(name = "月龄")
|
||||||
|
private Long monthAge;
|
||||||
|
|
||||||
|
/** 胎次 */
|
||||||
|
@Excel(name = "胎次")
|
||||||
|
private Integer parity;
|
||||||
|
|
||||||
|
/** 配次 */
|
||||||
|
@Excel(name = "配次")
|
||||||
|
private Integer matingCounts;
|
||||||
|
|
||||||
|
/** 当前羊舍 */
|
||||||
|
@Excel(name = "当前羊舍")
|
||||||
|
private String sheepfoldName;
|
||||||
|
|
||||||
|
/** 繁育状态 */
|
||||||
|
@Excel(name = "繁育状态")
|
||||||
|
private String breedStatus;
|
||||||
|
|
||||||
|
/** 配种公羊耳号 */
|
||||||
|
@Excel(name = "配种公羊")
|
||||||
|
private String fatherManageTags;
|
||||||
|
|
||||||
|
/** 配种公羊品种 */
|
||||||
|
@Excel(name = "配种公羊品种")
|
||||||
|
private String fatherVariety;
|
||||||
|
|
||||||
|
/** 配种类型 */
|
||||||
|
@Excel(name = "配种类型")
|
||||||
|
private String matingTypeName;
|
||||||
|
|
||||||
|
/** 配种日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "配种日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date matingDate;
|
||||||
|
|
||||||
|
/** 预产日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "预产日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date expectedDate;
|
||||||
|
|
||||||
|
/** 上次事件日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "上次事件日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date lastEventDate;
|
||||||
|
|
||||||
|
/** 所在牧场 */
|
||||||
|
@Excel(name = "所在牧场")
|
||||||
|
private String ranchName;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
@ -51,6 +123,26 @@ public class ScPregnancyRecord extends BaseEntity
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSheepId(Long sheepId)
|
||||||
|
{
|
||||||
|
this.sheepId = sheepId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSheepId()
|
||||||
|
{
|
||||||
|
return sheepId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManageTags(String manageTags)
|
||||||
|
{
|
||||||
|
this.manageTags = manageTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getManageTags()
|
||||||
|
{
|
||||||
|
return manageTags;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDatetime(Date datetime)
|
public void setDatetime(Date datetime)
|
||||||
{
|
{
|
||||||
this.datetime = datetime;
|
this.datetime = datetime;
|
||||||
@ -71,14 +163,14 @@ public class ScPregnancyRecord extends BaseEntity
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumber(Long number)
|
public void setFetusCount(Integer fetusCount)
|
||||||
{
|
{
|
||||||
this.number = number;
|
this.fetusCount = fetusCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getNumber()
|
public Integer getFetusCount()
|
||||||
{
|
{
|
||||||
return number;
|
return fetusCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTechnician(String technician)
|
public void setTechnician(String technician)
|
||||||
@ -91,27 +183,157 @@ public class ScPregnancyRecord extends BaseEntity
|
|||||||
return technician;
|
return technician;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWay(Long way)
|
public void setWay(String way)
|
||||||
{
|
{
|
||||||
this.way = way;
|
this.way = way;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getWay()
|
public String getWay()
|
||||||
{
|
{
|
||||||
return way;
|
return way;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark)
|
||||||
|
{
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark()
|
||||||
|
{
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDelete(Integer isDelete)
|
||||||
|
{
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsDelete()
|
||||||
|
{
|
||||||
|
return isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVariety() {
|
||||||
|
return variety;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariety(String variety) {
|
||||||
|
this.variety = variety;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMonthAge() {
|
||||||
|
return monthAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonthAge(Long monthAge) {
|
||||||
|
this.monthAge = monthAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParity() {
|
||||||
|
return parity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParity(Integer parity) {
|
||||||
|
this.parity = parity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMatingCounts() {
|
||||||
|
return matingCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMatingCounts(Integer matingCounts) {
|
||||||
|
this.matingCounts = matingCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSheepfoldName() {
|
||||||
|
return sheepfoldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSheepfoldName(String sheepfoldName) {
|
||||||
|
this.sheepfoldName = sheepfoldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBreedStatus() {
|
||||||
|
return breedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBreedStatus(String breedStatus) {
|
||||||
|
this.breedStatus = breedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFatherManageTags() {
|
||||||
|
return fatherManageTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFatherManageTags(String fatherManageTags) {
|
||||||
|
this.fatherManageTags = fatherManageTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFatherVariety() {
|
||||||
|
return fatherVariety;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFatherVariety(String fatherVariety) {
|
||||||
|
this.fatherVariety = fatherVariety;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMatingTypeName() {
|
||||||
|
return matingTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMatingTypeName(String matingTypeName) {
|
||||||
|
this.matingTypeName = matingTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getMatingDate() {
|
||||||
|
return matingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMatingDate(Date matingDate) {
|
||||||
|
this.matingDate = matingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpectedDate() {
|
||||||
|
return expectedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpectedDate(Date expectedDate) {
|
||||||
|
this.expectedDate = expectedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastEventDate() {
|
||||||
|
return lastEventDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastEventDate(Date lastEventDate) {
|
||||||
|
this.lastEventDate = lastEventDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRanchName() {
|
||||||
|
return ranchName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRanchName(String ranchName) {
|
||||||
|
this.ranchName = ranchName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
.append("datetime", getDatetime())
|
.append("sheepId", getSheepId())
|
||||||
.append("result", getResult())
|
.append("manageTags", getManageTags())
|
||||||
.append("number", getNumber())
|
.append("datetime", getDatetime())
|
||||||
.append("technician", getTechnician())
|
.append("result", getResult())
|
||||||
.append("way", getWay())
|
.append("fetusCount", getFetusCount())
|
||||||
.append("createBy", getCreateBy())
|
.append("technician", getTechnician())
|
||||||
.append("createTime", getCreateTime())
|
.append("way", getWay())
|
||||||
.toString();
|
.append("remark", getRemark())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("isDelete", getIsDelete())
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
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.ScPregnancyRecord;
|
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 孕检记录Mapper接口
|
* 孕检记录Mapper接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author zhyc
|
||||||
* @date 2025-07-17
|
* @date 2025-01-21
|
||||||
*/
|
*/
|
||||||
public interface ScPregnancyRecordMapper
|
public interface ScPregnancyRecordMapper
|
||||||
{
|
{
|
||||||
@ -59,4 +59,20 @@ public interface ScPregnancyRecordMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteScPregnancyRecordByIds(Long[] ids);
|
public int deleteScPregnancyRecordByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据耳号查询羊只信息
|
||||||
|
*
|
||||||
|
* @param manageTags 耳号
|
||||||
|
* @return 羊只信息
|
||||||
|
*/
|
||||||
|
public Map<String, Object> selectSheepByManageTags(String manageTags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新羊只基础表中的孕检相关字段
|
||||||
|
*
|
||||||
|
* @param params 更新参数
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSheepPregnancyInfo(Map<String, Object> params);
|
||||||
}
|
}
|
@ -1,15 +1,14 @@
|
|||||||
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.ScPregnancyRecord;
|
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 孕检记录Service接口
|
* 孕检记录Service接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author zhyc
|
||||||
* @date 2025-07-17
|
* @date 2025-01-21
|
||||||
*/
|
*/
|
||||||
public interface IScPregnancyRecordService
|
public interface IScPregnancyRecordService
|
||||||
{
|
{
|
||||||
@ -60,4 +59,12 @@ public interface IScPregnancyRecordService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteScPregnancyRecordById(Long id);
|
public int deleteScPregnancyRecordById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据耳号查询羊只信息
|
||||||
|
*
|
||||||
|
* @param manageTags 耳号
|
||||||
|
* @return 羊只信息
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getSheepByManageTags(String manageTags);
|
||||||
}
|
}
|
@ -1,19 +1,24 @@
|
|||||||
package com.zhyc.module.produce.breed.service.impl;
|
package com.zhyc.module.produce.breed.service.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
import com.zhyc.common.utils.DateUtils;
|
import com.zhyc.common.utils.DateUtils;
|
||||||
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
|
||||||
import com.zhyc.module.produce.breed.mapper.ScPregnancyRecordMapper;
|
|
||||||
import com.zhyc.module.produce.breed.service.IScPregnancyRecordService;
|
|
||||||
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 com.zhyc.module.produce.breed.mapper.ScPregnancyRecordMapper;
|
||||||
|
import com.zhyc.module.produce.breed.domain.ScPregnancyRecord;
|
||||||
|
import com.zhyc.module.produce.breed.service.IScPregnancyRecordService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 孕检记录Service业务层处理
|
* 孕检记录Service业务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author zhyc
|
||||||
* @date 2025-07-17
|
* @date 2025-01-21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
||||||
@ -52,10 +57,28 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int insertScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
public int insertScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
||||||
{
|
{
|
||||||
scPregnancyRecord.setCreateTime(DateUtils.getNowDate());
|
scPregnancyRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
return scPregnancyRecordMapper.insertScPregnancyRecord(scPregnancyRecord);
|
scPregnancyRecord.setIsDelete(0);
|
||||||
|
|
||||||
|
// 根据耳号获取羊只ID
|
||||||
|
if (scPregnancyRecord.getManageTags() != null) {
|
||||||
|
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags());
|
||||||
|
if (sheepInfo != null && sheepInfo.get("id") != null) {
|
||||||
|
scPregnancyRecord.setSheepId(Long.valueOf(sheepInfo.get("id").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = scPregnancyRecordMapper.insertScPregnancyRecord(scPregnancyRecord);
|
||||||
|
|
||||||
|
// 如果孕检结果为怀孕,更新羊只基础表相关字段
|
||||||
|
if ("怀孕".equals(scPregnancyRecord.getResult()) && scPregnancyRecord.getSheepId() != null) {
|
||||||
|
updateSheepPregnancyStatus(scPregnancyRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,9 +88,27 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int updateScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
public int updateScPregnancyRecord(ScPregnancyRecord scPregnancyRecord)
|
||||||
{
|
{
|
||||||
return scPregnancyRecordMapper.updateScPregnancyRecord(scPregnancyRecord);
|
scPregnancyRecord.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
|
// 根据耳号获取羊只ID
|
||||||
|
if (scPregnancyRecord.getManageTags() != null) {
|
||||||
|
Map<String, Object> sheepInfo = scPregnancyRecordMapper.selectSheepByManageTags(scPregnancyRecord.getManageTags());
|
||||||
|
if (sheepInfo != null && sheepInfo.get("id") != null) {
|
||||||
|
scPregnancyRecord.setSheepId(Long.valueOf(sheepInfo.get("id").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = scPregnancyRecordMapper.updateScPregnancyRecord(scPregnancyRecord);
|
||||||
|
|
||||||
|
// 如果孕检结果为怀孕,更新羊只基础表相关字段
|
||||||
|
if ("怀孕".equals(scPregnancyRecord.getResult()) && scPregnancyRecord.getSheepId() != null) {
|
||||||
|
updateSheepPregnancyStatus(scPregnancyRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,4 +134,46 @@ public class ScPregnancyRecordServiceImpl implements IScPregnancyRecordService
|
|||||||
{
|
{
|
||||||
return scPregnancyRecordMapper.deleteScPregnancyRecordById(id);
|
return scPregnancyRecordMapper.deleteScPregnancyRecordById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据耳号查询羊只信息
|
||||||
|
*
|
||||||
|
* @param manageTags 耳号
|
||||||
|
* @return 羊只信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getSheepByManageTags(String manageTags)
|
||||||
|
{
|
||||||
|
return scPregnancyRecordMapper.selectSheepByManageTags(manageTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新羊只怀孕状态
|
||||||
|
*
|
||||||
|
* @param scPregnancyRecord 孕检记录
|
||||||
|
*/
|
||||||
|
private void updateSheepPregnancyStatus(ScPregnancyRecord scPregnancyRecord) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("sheepId", scPregnancyRecord.getSheepId());
|
||||||
|
params.put("pregDate", scPregnancyRecord.getDatetime());
|
||||||
|
|
||||||
|
// 设置繁育状态为怀孕状态(假设怀孕状态ID为2)
|
||||||
|
params.put("breedStatusId", 2);
|
||||||
|
|
||||||
|
// 计算预产日期(羊的妊娠期大约150天)
|
||||||
|
if (scPregnancyRecord.getDatetime() != null) {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(scPregnancyRecord.getDatetime());
|
||||||
|
cal.add(Calendar.DAY_OF_YEAR, 150);
|
||||||
|
params.put("expectedDate", cal.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算怀孕天数
|
||||||
|
if (scPregnancyRecord.getDatetime() != null) {
|
||||||
|
long days = (System.currentTimeMillis() - scPregnancyRecord.getDatetime().getTime()) / (1000 * 60 * 60 * 24);
|
||||||
|
params.put("gestationDay", (int) days);
|
||||||
|
}
|
||||||
|
|
||||||
|
scPregnancyRecordMapper.updateSheepPregnancyInfo(params);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,60 +1,147 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScPregnancyRecordMapper">
|
<mapper namespace="com.zhyc.module.produce.breed.mapper.ScPregnancyRecordMapper">
|
||||||
|
|
||||||
<resultMap type="ScPregnancyRecord" id="ScPregnancyRecordResult">
|
<resultMap type="ScPregnancyRecord" id="ScPregnancyRecordResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
|
<result property="sheepId" column="sheep_id" />
|
||||||
|
<result property="manageTags" column="manage_tags" />
|
||||||
<result property="datetime" column="datetime" />
|
<result property="datetime" column="datetime" />
|
||||||
<result property="result" column="result" />
|
<result property="result" column="result" />
|
||||||
<result property="number" column="number" />
|
<result property="fetusCount" column="fetus_count" />
|
||||||
<result property="technician" column="technician" />
|
<result property="technician" column="technician" />
|
||||||
<result property="way" column="way" />
|
<result property="way" column="way" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="create_by" />
|
||||||
|
<result property="updateTime" column="create_time" />
|
||||||
|
<!-- 关联羊只信息字段 -->
|
||||||
|
<result property="variety" column="variety" />
|
||||||
|
<result property="monthAge" column="month_age" />
|
||||||
|
<result property="parity" column="parity" />
|
||||||
|
<result property="matingCounts" column="mating_counts" />
|
||||||
|
<result property="sheepfoldName" column="sheepfold_name" />
|
||||||
|
<result property="breedStatus" column="breed" />
|
||||||
|
<result property="fatherManageTags" column="father_manage_tags" />
|
||||||
|
<result property="fatherVariety" column="father_variety" />
|
||||||
|
<result property="matingTypeName" column="mating_type_name" />
|
||||||
|
<result property="matingDate" column="mating_date" />
|
||||||
|
<result property="expectedDate" column="expected_date" />
|
||||||
|
<result property="lastEventDate" column="last_event_date" />
|
||||||
|
<result property="ranchName" column="ranch" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectScPregnancyRecordVo">
|
<sql id="selectScPregnancyRecordVo">
|
||||||
select id, datetime, result, number, technician, way, create_by, create_time from sc_pregnancy_record
|
select
|
||||||
|
pr.id,
|
||||||
|
pr.sheep_id,
|
||||||
|
pr.datetime,
|
||||||
|
pr.result,
|
||||||
|
pr.fetus_count,
|
||||||
|
pr.technician,
|
||||||
|
pr.way,
|
||||||
|
pr.remark,
|
||||||
|
pr.create_by,
|
||||||
|
pr.create_time,
|
||||||
|
pr.create_by,
|
||||||
|
pr.create_time,
|
||||||
|
sf.bs_manage_tags as manage_tags,
|
||||||
|
sf.variety,
|
||||||
|
sf.month_age,
|
||||||
|
sf.parity,
|
||||||
|
sf.mating_counts,
|
||||||
|
sf.sheepfold_name,
|
||||||
|
sf.breed,
|
||||||
|
sf.father_manage_tags,
|
||||||
|
father_sf.variety as father_variety,
|
||||||
|
mating_type.dict_label as mating_type_name,
|
||||||
|
sf.mating_date,
|
||||||
|
sf.expected_date,
|
||||||
|
sf.lambing_date as last_event_date,
|
||||||
|
r.ranch as ranch
|
||||||
|
from sc_pregnancy_record pr
|
||||||
|
left join sheep_file sf on pr.sheep_id = sf.id
|
||||||
|
left join sys_dict_data mating_type on sf.mating_type_id = mating_type.dict_value and mating_type.dict_type = 'breed_type' and mating_type.status = '0'
|
||||||
|
left join da_ranch r on sf.ranch_id = r.id
|
||||||
|
left join sheep_file father_sf on sf.bs_father_id = father_sf.id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
<select id="selectScPregnancyRecordList" parameterType="ScPregnancyRecord" resultMap="ScPregnancyRecordResult">
|
||||||
<include refid="selectScPregnancyRecordVo"/>
|
<include refid="selectScPregnancyRecordVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="datetime != null "> and datetime = #{datetime}</if>
|
pr.is_delete = 0
|
||||||
<if test="result != null and result != ''"> and result = #{result}</if>
|
<if test="manageTags != null and manageTags != ''">
|
||||||
<if test="number != null "> and number = #{number}</if>
|
<choose>
|
||||||
<if test="technician != null and technician != ''"> and technician = #{technician}</if>
|
<when test="manageTags.contains(',')">
|
||||||
<if test="way != null "> and way = #{way}</if>
|
and sf.bs_manage_tags in
|
||||||
|
<foreach item="tag" collection="manageTags.split(',')" open="(" separator="," close=")">
|
||||||
|
#{tag}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
and sf.bs_manage_tags like concat('%', #{manageTags}, '%')
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
<if test="datetime != null "> and pr.datetime = #{datetime}</if>
|
||||||
|
<if test="result != null and result != ''"> and pr.result = #{result}</if>
|
||||||
|
<if test="technician != null and technician != ''"> and pr.technician like concat('%', #{technician}, '%')</if>
|
||||||
|
<if test="way != null and way != ''"> and pr.way = #{way}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by pr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectScPregnancyRecordById" parameterType="Long" resultMap="ScPregnancyRecordResult">
|
<select id="selectScPregnancyRecordById" parameterType="Long" resultMap="ScPregnancyRecordResult">
|
||||||
<include refid="selectScPregnancyRecordVo"/>
|
<include refid="selectScPregnancyRecordVo"/>
|
||||||
where id = #{id}
|
where pr.id = #{id} and pr.is_delete = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据耳号查询羊只信息 -->
|
||||||
|
<select id="selectSheepByManageTags" parameterType="String" resultType="map">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
bs_manage_tags as manageTags,
|
||||||
|
variety,
|
||||||
|
month_age as monthAge,
|
||||||
|
parity,
|
||||||
|
mating_counts as matingCounts,
|
||||||
|
sheepfold_name as sheepfoldName,
|
||||||
|
breed as breedStatus
|
||||||
|
from sheep_file
|
||||||
|
where bs_manage_tags = #{manageTags}
|
||||||
|
and is_delete = 0
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertScPregnancyRecord" parameterType="ScPregnancyRecord" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sc_pregnancy_record
|
insert into sc_pregnancy_record
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="sheepId != null">sheep_id,</if>
|
||||||
<if test="datetime != null">datetime,</if>
|
<if test="datetime != null">datetime,</if>
|
||||||
<if test="result != null">result,</if>
|
<if test="result != null">result,</if>
|
||||||
<if test="number != null">number,</if>
|
<if test="fetusCount != null">fetus_count,</if>
|
||||||
<if test="technician != null">technician,</if>
|
<if test="technician != null">technician,</if>
|
||||||
<if test="way != null">way,</if>
|
<if test="way != null">way,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
</trim>
|
is_delete
|
||||||
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="sheepId != null">#{sheepId},</if>
|
||||||
<if test="datetime != null">#{datetime},</if>
|
<if test="datetime != null">#{datetime},</if>
|
||||||
<if test="result != null">#{result},</if>
|
<if test="result != null">#{result},</if>
|
||||||
<if test="number != null">#{number},</if>
|
<if test="fetusCount != null">#{fetusCount},</if>
|
||||||
<if test="technician != null">#{technician},</if>
|
<if test="technician != null">#{technician},</if>
|
||||||
<if test="way != null">#{way},</if>
|
<if test="way != null">#{way},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
</trim>
|
0
|
||||||
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateScPregnancyRecord" parameterType="ScPregnancyRecord">
|
<update id="updateScPregnancyRecord" parameterType="ScPregnancyRecord">
|
||||||
@ -62,23 +149,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="datetime != null">datetime = #{datetime},</if>
|
<if test="datetime != null">datetime = #{datetime},</if>
|
||||||
<if test="result != null">result = #{result},</if>
|
<if test="result != null">result = #{result},</if>
|
||||||
<if test="number != null">number = #{number},</if>
|
<if test="fetusCount != null">fetus_count = #{fetusCount},</if>
|
||||||
<if test="technician != null">technician = #{technician},</if>
|
<if test="technician != null">technician = #{technician},</if>
|
||||||
<if test="way != null">way = #{way},</if>
|
<if test="way != null">way = #{way},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateBy != null">create_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">create_time = #{updateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteScPregnancyRecordById" parameterType="Long">
|
<update id="deleteScPregnancyRecordById" parameterType="Long">
|
||||||
delete from sc_pregnancy_record where id = #{id}
|
update sc_pregnancy_record set is_delete = 1 where id = #{id}
|
||||||
</delete>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteScPregnancyRecordByIds" parameterType="String">
|
<update id="deleteScPregnancyRecordByIds" parameterType="String">
|
||||||
delete from sc_pregnancy_record where id in
|
update sc_pregnancy_record set is_delete = 1 where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</update>
|
||||||
|
|
||||||
|
<!-- 更新羊只基础表中的孕检相关字段 -->
|
||||||
|
<update id="updateSheepPregnancyInfo" parameterType="map">
|
||||||
|
update bas_sheep
|
||||||
|
<set>
|
||||||
|
<if test="pregDate != null">preg_date = #{pregDate},</if>
|
||||||
|
<if test="breedStatusId != null">breed_status_id = #{breedStatusId},</if>
|
||||||
|
<if test="expectedDate != null">expected_date = #{expectedDate},</if>
|
||||||
|
<if test="gestationDay != null">gestation_day = #{gestationDay},</if>
|
||||||
|
create_time = now()
|
||||||
|
</set>
|
||||||
|
where id = #{sheepId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user