Compare commits

...

2 Commits

11 changed files with 218 additions and 181 deletions

View File

@ -5,10 +5,12 @@ import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType; import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.exception.ServiceException; import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.poi.ExcelUtil; import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
import com.zhyc.module.base.variety.service.IBasSheepVarietyService;
import com.zhyc.module.fileManagement.domain.DaSheepfold;
import com.zhyc.module.fileManagement.service.IDaSheepfoldService;
import com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep; import com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep;
import com.zhyc.module.produce.manage_sheep.add_sheep.service.IScAddSheepService; import com.zhyc.module.produce.manage_sheep.add_sheep.service.IScAddSheepService;
import com.zhyc.module.sheepfold_management.domain.DaSheepfold;
import com.zhyc.module.sheepfold_management.service.IDaSheepfoldService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -33,6 +35,8 @@ public class ScAddSheepController {
@Autowired @Autowired
private IDaSheepfoldService daSheepfoldMapper; private IDaSheepfoldService daSheepfoldMapper;
@Autowired
private IBasSheepVarietyService basSheepVarietyService;
//新增羊只验证 //新增羊只验证
@PreAuthorize("@ss.hasPermi('produce:add_sheep:add')") @PreAuthorize("@ss.hasPermi('produce:add_sheep:add')")
@Log(title = "新增", businessType = BusinessType.INSERT) @Log(title = "新增", businessType = BusinessType.INSERT)
@ -83,7 +87,12 @@ public class ScAddSheepController {
scAddSheep.setSheepfoldNameExcel(fold.getSheepfoldName()); scAddSheep.setSheepfoldNameExcel(fold.getSheepfoldName());
} }
} }
if (scAddSheep.getVarietyId() != null) {
BasSheepVariety variety = basSheepVarietyService.selectBasSheepVarietyById(scAddSheep.getVarietyId().longValue());
if (variety != null) {
scAddSheep.setVarietyName(variety.getVariety());
}
}
list.add(scAddSheep); list.add(scAddSheep);
util.exportExcel(response, list, "羊只信息"); util.exportExcel(response, list, "羊只信息");
} }

View File

@ -52,18 +52,21 @@ public class ScAddSheep extends BaseEntity {
@Excel(name = "出生日期", dateFormat = "yyyy-MM-dd") @Excel(name = "出生日期", dateFormat = "yyyy-MM-dd")
private Date birthday; private Date birthday;
/** 性别 1公 0母 */ /** 性别 1公 0母 2阉羊 3兼性 */
@Excel(name = "性别", readConverterExp = "1=公,0=母") @Excel(name = "性别", readConverterExp = "1=公,0=母,2=阉羊,3=兼性")
private Integer gender; private Integer gender;
/** 胎次 */ /** 胎次 */
@Excel(name = "胎次") @Excel(name = "胎次")
private Integer parity; private Integer parity;
/** 品种编号 */ /** 品种id */
@Excel(name = "品种编号")
private Integer varietyId; private Integer varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** 入群日期 */ /** 入群日期 */
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd") @Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")
private Date joinDate; private Date joinDate;

View File

@ -2,20 +2,23 @@ package com.zhyc.module.produce.manage_sheep.add_sheep.service.impl;
import com.zhyc.common.exception.ServiceException; import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.StringUtils; import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.variety.domain.BasSheepVariety;
import com.zhyc.module.base.variety.service.IBasSheepVarietyService;
import com.zhyc.module.fileManagement.domain.DaSheepfold;
import com.zhyc.module.fileManagement.mapper.DaSheepfoldMapper;
import com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep; import com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep;
import com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper; import com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper;
import com.zhyc.module.produce.manage_sheep.add_sheep.service.IScAddSheepService; import com.zhyc.module.produce.manage_sheep.add_sheep.service.IScAddSheepService;
import com.zhyc.module.produce.sheep.domain.BasSheep; import com.zhyc.module.produce.sheep.domain.BasSheep;
import com.zhyc.module.produce.sheep.mapper.BasSheepMapper;
import com.zhyc.module.produce.sheep.service.IBasSheepService; import com.zhyc.module.produce.sheep.service.IBasSheepService;
import com.zhyc.module.produce.sheep.service.impl.BasSheepServiceImpl;
import com.zhyc.module.sheepfold_management.domain.DaSheepfold;
import com.zhyc.module.sheepfold_management.mapper.DaSheepfoldMapper;
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 java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
public class ScAddSheepServiceImpl implements IScAddSheepService { public class ScAddSheepServiceImpl implements IScAddSheepService {
@ -29,6 +32,9 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
@Autowired @Autowired
private IBasSheepService basSheepService; private IBasSheepService basSheepService;
@Autowired
private IBasSheepVarietyService basSheepVarietyService;
@Override @Override
public boolean insertScAddSheep(ScAddSheep scAddSheep) { public boolean insertScAddSheep(ScAddSheep scAddSheep) {
// 1. 重复校验 // 1. 重复校验
@ -62,6 +68,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
basSheepService.insertBasSheep(bs); basSheepService.insertBasSheep(bs);
return true; return true;
} }
@Override @Override
public List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep) { public List<ScAddSheep> selectScAddSheepList(ScAddSheep scAddSheep) {
return scAddSheepMapper.selectScAddSheepList(scAddSheep); return scAddSheepMapper.selectScAddSheepList(scAddSheep);
@ -79,6 +86,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
/* ------------------ 导入:羊舍名称 → ID ------------------ */ /* ------------------ 导入:羊舍名称 → ID ------------------ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName) { public String importSheep(List<ScAddSheep> list, boolean updateSupport, String operName) {
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
throw new ServiceException("导入数据不能为空!"); throw new ServiceException("导入数据不能为空!");
@ -87,50 +95,58 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
int success = 0, failure = 0; int success = 0, failure = 0;
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
// 1. 一次性加载全部品种和羊舍避免循环查库
Map<String, Long> varietyNameToIdMap = basSheepVarietyService
.selectBasSheepVarietyList(new BasSheepVariety())
.stream()
.collect(Collectors.toMap(
BasSheepVariety::getVariety,
BasSheepVariety::getId,
(existing, replacement) -> existing // 保留第一个
));
Map<String, Long> sheepfoldNameToIdMap = daSheepfoldMapper
.selectDaSheepfoldList(new DaSheepfold())
.stream()
.collect(Collectors.toMap(
DaSheepfold::getSheepfoldName,
DaSheepfold::getId,
(existing, replacement) -> existing // 保留第一个
));
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
ScAddSheep sheep = list.get(i); ScAddSheep sheep = list.get(i);
try { try {
/* 1. 羊舍名称 → ID */ // 2. 羊舍名称 ID
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) { if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
DaSheepfold param = new DaSheepfold(); Long sheepfoldId = sheepfoldNameToIdMap.get(sheep.getSheepfoldNameExcel());
param.setSheepfoldName(sheep.getSheepfoldNameExcel()); if (sheepfoldId == null) {
List<DaSheepfold> foldList = daSheepfoldMapper.selectDaSheepfoldList(param); throw new ServiceException("羊舍名称不存在:" + sheep.getSheepfoldNameExcel());
if (foldList == null || foldList.isEmpty()) {
failure++;
failureMsg.append("<br/>第")
.append(i + 1)
.append("行:羊舍名称不存在【")
.append(sheep.getSheepfoldNameExcel())
.append("");
continue;
} }
sheep.setSheepfold(foldList.get(0).getId().intValue()); sheep.setSheepfold(sheepfoldId.intValue());
} }
/* 2. 耳号非空校验 */ // 3. 品种名称 ID
if (StringUtils.isNotBlank(sheep.getVarietyName())) {
Long varietyId = varietyNameToIdMap.get(sheep.getVarietyName());
if (varietyId == null) {
throw new ServiceException("品种名称不存在:" + sheep.getVarietyName());
}
sheep.setVarietyId(varietyId.intValue());
}
// 4. 耳号非空校验
if (StringUtils.isBlank(sheep.getEarNumber())) { if (StringUtils.isBlank(sheep.getEarNumber())) {
failure++; throw new ServiceException("耳号不能为空");
failureMsg.append("<br/>第")
.append(i + 1)
.append("行:耳号不能为空");
continue;
} }
/* 3. 耳号重复校验(增量导入核心) */ // 5. 耳号重复校验
ScAddSheep exist = scAddSheepMapper.selectByEarNumber(sheep.getEarNumber()); ScAddSheep exist = scAddSheepMapper.selectByEarNumber(sheep.getEarNumber());
if (exist != null) { if (exist != null) {
failure++; if (!updateSupport) {
failureMsg.append("<br/>第") throw new ServiceException("耳号已存在:" + sheep.getEarNumber());
.append(i + 1) }
.append("行:耳号已存在【") sheep.setId(exist.getId());
.append(sheep.getEarNumber())
.append("");
continue;
}
/* 4. 插入或更新 */
if (updateSupport && sheep.getId() != null) {
sheep.setUpdateBy(operName); sheep.setUpdateBy(operName);
updateScAddSheep(sheep); updateScAddSheep(sheep);
} else { } else {
@ -140,10 +156,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
success++; success++;
} catch (Exception e) { } catch (Exception e) {
failure++; failure++;
failureMsg.append("<br/>第") failureMsg.append("<br/>第").append(i + 1).append("行:").append(e.getMessage());
.append(i + 1)
.append("行:")
.append(e.getMessage());
} }
} }

View File

@ -44,6 +44,13 @@ public class ScTransGroup extends BaseEntity
private String foldToName; private String foldToName;
/** 转群原因 */ /** 转群原因 */
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
private Integer reason; private Integer reason;
/** 转群原因描述 用于导出*/ /** 转群原因描述 用于导出*/
@Excel(name = "转群原因") @Excel(name = "转群原因")

View File

@ -51,8 +51,6 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
group.setStatusText(convertStatus(group.getStatus())); group.setStatusText(convertStatus(group.getStatus()));
}); });
return list; return list;
// return scTransGroupMapper.selectScTransGroupList(scTransGroup);
} }
/** /**

View File

@ -1,5 +1,8 @@
package com.zhyc.module.produce.other.castrate.domain; package com.zhyc.module.produce.other.castrate.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
@ -11,6 +14,9 @@ import com.zhyc.common.core.domain.BaseEntity;
* @author ruoyi * @author ruoyi
* @date 2025-07-09 * @date 2025-07-09
*/ */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScCastrate extends BaseEntity { public class ScCastrate extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -36,6 +42,13 @@ public class ScCastrate extends BaseEntity {
@Excel(name = "羊舍名称") @Excel(name = "羊舍名称")
private String sheepfoldName; private String sheepfoldName;
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** /**
* 备注 * 备注
*/ */
@ -50,63 +63,5 @@ public class ScCastrate extends BaseEntity {
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setSheepId(String sheepId) {
this.sheepId = sheepId;
}
public String getSheepId() {
return sheepId;
}
public void setSheepfold(Long sheepfold) {
this.sheepfold = sheepfold;
}
public Long getSheepfold() {
return sheepfold;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getComment() {
return comment;
}
public void setTechnician(String technician) {
this.technician = technician;
}
public String getTechnician() {
return technician;
}
public String getSheepfoldName() {
return sheepfoldName;
}
public void setSheepfoldName(String sheepfoldName) {
this.sheepfoldName = sheepfoldName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("sheepId", getSheepId())
.append("sheepfold", getSheepfold())
.append("comment", getComment())
.append("technician", getTechnician())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
} }

View File

@ -35,6 +35,13 @@ public class ScFixHoof extends BaseEntity
@Excel(name = "羊舍名称") @Excel(name = "羊舍名称")
private String sheepfoldName; private String sheepfoldName;
/** 品种id */
private Long varietyId;
/** 品种名称(联表查询返回,非数据库字段) */
@Excel(name = "品种")
private String varietyName;
/** 备注 */ /** 备注 */
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;

View File

@ -4,78 +4,94 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper"> <mapper namespace="com.zhyc.module.produce.manage_sheep.add_sheep.mapper.ScAddSheepMapper">
<!-- 1. 结果映射:包含羊舍名称、品种名称 -->
<resultMap type="com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep" id="ScAddSheepResult"> <resultMap type="com.zhyc.module.produce.manage_sheep.add_sheep.domain.ScAddSheep" id="ScAddSheepResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="earNumber" column="ear_number"/> <result property="earNumber" column="ear_number"/>
<result property="sheepfold" column="sheepfold"/> <result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/> <result property="sheepfoldName" column="sheepfoldName"/>
<result property="sheepfoldNameExcel" column="sheepfoldName"/> <result property="father" column="father"/>
<result property="father" column="father"/> <result property="mother" column="mother"/>
<result property="mother" column="mother"/> <result property="bornWeight" column="born_weight"/>
<result property="bornWeight" column="born_weight"/> <result property="birthday" column="birthday"/>
<result property="birthday" column="birthday"/> <result property="gender" column="gender"/>
<result property="gender" column="gender"/> <result property="parity" column="parity"/>
<result property="parity" column="parity"/> <result property="varietyId" column="variety_id"/>
<result property="varietyId" column="variety_id"/> <result property="varietyName" column="varietyName"/>
<result property="joinDate" column="join_date"/> <result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/> <result property="comment" column="comment"/>
<result property="technician" column="technician"/> <result property="technician" column="technician"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
</resultMap> </resultMap>
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id"> <!-- 2. 查询列表:支持按品种筛选 -->
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday, gender, parity,
variety_id, join_date, comment, technician, create_by, create_time)
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight}, #{birthday},
#{gender}, #{parity}, #{varietyId}, #{joinDate}, #{comment}, #{technician},
#{createBy}, #{createTime})
</insert>
<select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult"> <select id="selectScAddSheepList" parameterType="ScAddSheep" resultMap="ScAddSheepResult">
SELECT SELECT
sas.*, sas.*,
sf.sheepfold_name AS sheepfoldName sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName
FROM sc_add_sheep sas FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
<where> <where>
<if test="earNumber != null and earNumber != ''"> <if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%') AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
</if> </if>
<if test="sheepfold != null">
AND sas.sheepfold = #{sheepfold}
</if>
<if test="varietyId != null">
AND sas.variety_id = #{varietyId}
</if>
</where> </where>
</select> </select>
<!-- 3. 根据耳号精确查询 -->
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
<!-- 4. 插入 -->
<insert id="insert" parameterType="ScAddSheep" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sc_add_sheep
(ear_number, sheepfold, father, mother, born_weight, birthday,
gender, parity, variety_id, join_date, comment, technician,
create_by, create_time)
VALUES
(#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
</insert>
<!-- 5. 更新 -->
<update id="updateScAddSheep" parameterType="ScAddSheep"> <update id="updateScAddSheep" parameterType="ScAddSheep">
UPDATE sc_add_sheep UPDATE sc_add_sheep
<set> <set>
ear_number = #{earNumber}, ear_number = #{earNumber},
sheepfold = #{sheepfold}, sheepfold = #{sheepfold},
father = #{father}, father = #{father},
mother = #{mother}, mother = #{mother},
born_weight = #{bornWeight}, born_weight = #{bornWeight},
birthday = #{birthday}, birthday = #{birthday},
gender = #{gender}, gender = #{gender},
parity = #{parity}, parity = #{parity},
variety_id = #{varietyId}, variety_id = #{varietyId},
join_date = #{joinDate}, join_date = #{joinDate},
comment = #{comment}, comment = #{comment},
technician = #{technician}, technician = #{technician},
update_by = #{updateBy}, update_by = #{updateBy},
update_time = NOW() update_time = NOW()
</set> </set>
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<!-- 6. 批量删除 -->
<delete id="deleteScAddSheepByIds"> <delete id="deleteScAddSheepByIds">
DELETE FROM sc_add_sheep WHERE id IN DELETE FROM sc_add_sheep WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")"> <foreach collection="array" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectByEarNumber" parameterType="string" resultMap="ScAddSheepResult">
SELECT * FROM sc_add_sheep WHERE ear_number = #{earNumber}
</select>
</mapper> </mapper>

View File

@ -10,6 +10,8 @@
<result property="foldTo" column="fold_to"/> <result property="foldTo" column="fold_to"/>
<result property="foldFrom" column="fold_from"/> <result property="foldFrom" column="fold_from"/>
<result property="reason" column="reason"/> <result property="reason" column="reason"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="technician" column="technician"/> <result property="technician" column="technician"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="comment" column="comment"/> <result property="comment" column="comment"/>
@ -23,6 +25,8 @@
tg.fold_to, tg.fold_to,
tg.fold_from, tg.fold_from,
tg.reason, tg.reason,
tg.variety_id,
bv.variety AS varietyName,
tg.technician, tg.technician,
tg.status, tg.status,
tg.comment, tg.comment,
@ -33,15 +37,17 @@
FROM sc_trans_group tg FROM sc_trans_group tg
LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id
LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id
LEFT JOIN bas_sheep_variety bv ON tg.variety_id = bv.id
</sql> </sql>
<select id="selectScTransGroupList" parameterType="ScTransGroup" resultMap="ScTransGroupResult"> <select id="selectScTransGroupList" parameterType="ScTransGroup" resultMap="ScTransGroupResult">
<include refid="selectScTransGroupVo"/> <include refid="selectScTransGroupVo"/>
<where> <where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if> <if test="sheepId != null">and sheep_id = #{sheepId}</if>
<if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if> <if test="foldTo != null and foldTo != ''">and fold_to = #{foldTo}</if>
<if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if> <if test="foldFrom != null and foldFrom != ''">and fold_from = #{foldFrom}</if>
<if test="status != null ">and status = #{status}</if> <if test="status != null">and status = #{status}</if>
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime} and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if> </if>
@ -54,13 +60,15 @@
where tg.id = #{id} where tg.id = #{id}
</select> </select>
<insert id="insertScTransGroup" parameterType="ScTransGroup" useGeneratedKeys="true" keyProperty="id"> <insert id="insertScTransGroup" parameterType="ScTransGroup"
useGeneratedKeys="true" keyProperty="id">
insert into sc_trans_group insert into sc_trans_group
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if> <if test="sheepId != null">sheep_id,</if>
<if test="foldTo != null and foldTo != ''">fold_to,</if> <if test="foldTo != null and foldTo != ''">fold_to,</if>
<if test="foldFrom != null and foldFrom != ''">fold_from,</if> <if test="foldFrom != null and foldFrom != ''">fold_from,</if>
<if test="reason != null and reason != ''">reason,</if> <if test="varietyId != null">variety_id,</if>
<if test="reason != null">reason,</if>
<if test="technician != null and technician != ''">technician,</if> <if test="technician != null and technician != ''">technician,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="comment != null">comment,</if> <if test="comment != null">comment,</if>
@ -71,7 +79,8 @@
<if test="sheepId != null">#{sheepId},</if> <if test="sheepId != null">#{sheepId},</if>
<if test="foldTo != null and foldTo != ''">#{foldTo},</if> <if test="foldTo != null and foldTo != ''">#{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if> <if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if>
<if test="reason != null and reason != ''">#{reason},</if> <if test="varietyId != null">#{varietyId},</if>
<if test="reason != null">#{reason},</if>
<if test="technician != null and technician != ''">#{technician},</if> <if test="technician != null and technician != ''">#{technician},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="comment != null">#{comment},</if> <if test="comment != null">#{comment},</if>
@ -86,14 +95,15 @@
<if test="sheepId != null">sheep_id = #{sheepId},</if> <if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if> <if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if> <if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if>
<if test="reason != null and reason != ''">reason = #{reason},</if> <if test="varietyId != null">variety_id = #{varietyId},</if>
<if test="reason != null">reason = #{reason},</if>
<if test="technician != null and technician != ''">technician = #{technician},</if> <if test="technician != null and technician != ''">technician = #{technician},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</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="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
</trim> </trim>
where sc_trans_group.id = #{id} where id = #{id}
</update> </update>
<delete id="deleteScTransGroupById" parameterType="Integer"> <delete id="deleteScTransGroupById" parameterType="Integer">

View File

@ -9,6 +9,7 @@
<result property="sheepId" column="sheep_id"/> <result property="sheepId" column="sheep_id"/>
<result property="sheepfold" column="sheepfold"/> <result property="sheepfold" column="sheepfold"/>
<result property="comment" column="comment"/> <result property="comment" column="comment"/>
<result property="varietyId" column="variety_id"/>
<result property="technician" column="technician"/> <result property="technician" column="technician"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
@ -19,12 +20,15 @@
sc.sheep_id, sc.sheep_id,
sc.sheepfold, sc.sheepfold,
sf.sheepfold_name as sheepfoldName, sf.sheepfold_name as sheepfoldName,
sc.variety_id,
bv.variety as varietyName,
sc.comment, sc.comment,
sc.technician, sc.technician,
sc.create_by, sc.create_by,
sc.create_time sc.create_time
from sc_castrate sc from sc_castrate sc
left join da_sheepfold sf on sc.sheepfold = sf.id left join da_sheepfold sf on sc.sheepfold = sf.id
left join bas_sheep_variety bv on sc.variety_id = bv.id
</sql> </sql>
<select id="selectScCastrateList" parameterType="ScCastrate" resultMap="ScCastrateResult"> <select id="selectScCastrateList" parameterType="ScCastrate" resultMap="ScCastrateResult">
@ -32,10 +36,14 @@
<where> <where>
<if test="sheepId != null and sheepId != ''">and sheep_id like concat('%', #{sheepId}, '%')</if> <if test="sheepId != null and sheepId != ''">and sheep_id like concat('%', #{sheepId}, '%')</if>
<if test="sheepfold != null ">and sheepfold like concat('%', #{sheepfold}, '%')</if> <if test="sheepfold != null ">and sheepfold like concat('%', #{sheepfold}, '%')</if>
<if test="varietyId != null">
and sc.variety_id = #{varietyId}
</if>
<if test="technician != null and technician != ''">and technician like concat('%', #{technician}, '%')</if> <if test="technician != null and technician != ''">and technician like concat('%', #{technician}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime} and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if> </if>
</where> </where>
</select> </select>
@ -49,6 +57,7 @@
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if> <if test="sheepId != null">sheep_id,</if>
<if test="sheepfold != null">sheepfold,</if> <if test="sheepfold != null">sheepfold,</if>
<if test="varietyId != null">variety_id,</if>
<if test="comment != null">comment,</if> <if test="comment != null">comment,</if>
<if test="technician != null">technician,</if> <if test="technician != null">technician,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
@ -57,6 +66,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if> <if test="sheepId != null">#{sheepId},</if>
<if test="sheepfold != null">#{sheepfold},</if> <if test="sheepfold != null">#{sheepfold},</if>
<if test="varietyId != null">#{varietyId},</if>
<if test="comment != null">#{comment},</if> <if test="comment != null">#{comment},</if>
<if test="technician != null">#{technician},</if> <if test="technician != null">#{technician},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
@ -69,6 +79,7 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if> <if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="sheepfold != null">sheepfold = #{sheepfold},</if> <if test="sheepfold != null">sheepfold = #{sheepfold},</if>
<if test="varietyId != null">variety_id = #{varietyId},</if>
<if test="comment != null">comment = #{comment},</if> <if test="comment != null">comment = #{comment},</if>
<if test="technician != null">technician = #{technician},</if> <if test="technician != null">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>

View File

@ -8,6 +8,7 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/> <result property="sheepId" column="sheep_id"/>
<result property="sheepfold" column="sheepfold"/> <result property="sheepfold" column="sheepfold"/>
<result property="varietyId" column="variety_id"/>
<result property="sheepfoldName" column="sheepfoldName"/> <result property="sheepfoldName" column="sheepfoldName"/>
<result property="comment" column="comment"/> <result property="comment" column="comment"/>
<result property="technician" column="technician"/> <result property="technician" column="technician"/>
@ -20,12 +21,15 @@
fh.sheep_id, fh.sheep_id,
fh.sheepfold, fh.sheepfold,
sf.sheepfold_name as sheepfoldName, sf.sheepfold_name as sheepfoldName,
fh.variety_id,
bv.variety as varietyName,
fh.comment, fh.comment,
fh.technician, fh.technician,
fh.create_by, fh.create_by,
fh.create_time fh.create_time
from sc_fix_hoof fh from sc_fix_hoof fh
left join da_sheepfold sf on fh.sheepfold = sf.id left join da_sheepfold sf on fh.sheepfold = sf.id
left join bas_sheep_variety bv on fh.variety_id = bv.id
</sql> </sql>
<select id="selectScFixHoofList" parameterType="ScFixHoof" resultMap="ScFixHoofResult"> <select id="selectScFixHoofList" parameterType="ScFixHoof" resultMap="ScFixHoofResult">
@ -33,6 +37,9 @@
<where> <where>
<if test="sheepId != null ">and sheep_id = #{sheepId}</if> <if test="sheepId != null ">and sheep_id = #{sheepId}</if>
<if test="sheepfold != null ">and sheepfold = #{sheepfold}</if> <if test="sheepfold != null ">and sheepfold = #{sheepfold}</if>
<if test="varietyId != null">
and fh.variety_id = #{varietyId}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime} and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if> </if>
@ -44,24 +51,24 @@
where fh.id = #{id} where fh.id = #{id}
</select> </select>
<insert id="insertScFixHoof" parameterType="ScFixHoof" useGeneratedKeys="true" keyProperty="id"> <insert id="insertScFixHoof" parameterType="ScFixHoof"
insert into sc_fix_hoof useGeneratedKeys="true" keyProperty="id">
<trim prefix="(" suffix=")" suffixOverrides=","> INSERT INTO sc_fix_hoof
<if test="sheepId != null and sheepId != ''">and fh.sheep_id like concat('%', #{sheepId}, '%')</if> (sheep_id,
<if test="sheepfold != null">and fh.sheepfold = #{sheepfold}</if> sheepfold,
<if test="comment != null">comment,</if> variety_id,
<if test="technician != null and technician != ''">technician,</if> <if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if> <if test="technician != null and technician != ''">technician,</if>
<if test="createTime != null">create_time,</if> create_by,
</trim> create_time)
<trim prefix="values (" suffix=")" suffixOverrides=","> VALUES
<if test="sheepId != null">#{sheepId},</if> (#{sheepId},
<if test="sheepfold != null">#{sheepfold},</if> #{sheepfold},
<if test="comment != null">#{comment},</if> <if test="varietyId != null">#{varietyId},</if>
<if test="technician != null and technician != ''">#{technician},</if> <if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if> <if test="technician != null and technician != ''">#{technician},</if>
<if test="createTime != null">#{createTime},</if> #{createBy},
</trim> #{createTime})
</insert> </insert>
<update id="updateScFixHoof" parameterType="ScFixHoof"> <update id="updateScFixHoof" parameterType="ScFixHoof">
@ -69,6 +76,7 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if> <if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="sheepfold != null">sheepfold = #{sheepfold},</if> <if test="sheepfold != null">sheepfold = #{sheepfold},</if>
<if test="varietyId != null">variety_id=#{varietyId},</if>
<if test="comment != null">comment = #{comment},</if> <if test="comment != null">comment = #{comment},</if>
<if test="technician != null and technician != ''">technician = #{technician},</if> <if test="technician != null and technician != ''">technician = #{technician},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>