Compare commits

...

2 Commits

24 changed files with 265 additions and 56 deletions

View File

@ -5,7 +5,9 @@ import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.module.base.domain.BasSheepType;
import com.zhyc.module.base.domain.BasSheepVariety;
import com.zhyc.module.base.service.IBasSheepTypeService;
import com.zhyc.module.base.service.IBasSheepVarietyService;
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
@ -36,6 +38,8 @@ public class ScAddSheepController {
private IDaSheepfoldService daSheepfoldMapper;
@Autowired
private IBasSheepVarietyService basSheepVarietyMapper;
@Autowired
private IBasSheepTypeService basSheepTypeService;
//新增羊只验证
@PreAuthorize("@ss.hasPermi('produce:add_sheep:add')")
@Log(title = "新增", businessType = BusinessType.INSERT)
@ -79,8 +83,7 @@ public class ScAddSheepController {
public void exportForm(HttpServletResponse response, @RequestBody ScAddSheep scAddSheep) throws IOException {
ExcelUtil<ScAddSheep> util = new ExcelUtil<>(ScAddSheep.class);
List<ScAddSheep> list = new ArrayList<>();
// 处理羊舍名称原有逻辑
// 处理羊舍名称
if (scAddSheep.getSheepfold() != null) {
DaSheepfold fold = daSheepfoldMapper.selectDaSheepfoldById(scAddSheep.getSheepfold().longValue());
if (fold != null) {
@ -88,6 +91,7 @@ public class ScAddSheepController {
}
}
//处理羊只品种名称
if (scAddSheep.getVarietyId() != null) {
BasSheepVariety variety = basSheepVarietyMapper.selectBasSheepVarietyById(scAddSheep.getVarietyId().longValue());
if (variety != null) {
@ -95,6 +99,13 @@ public class ScAddSheepController {
}
}
//处理羊只类型名称
if (scAddSheep.getTypeId() != null) {
BasSheepType sheepType = basSheepTypeService.selectBasSheepTypeById(scAddSheep.getTypeId().intValue());
if (sheepType != null) {
scAddSheep.setTypeName(sheepType.getName());
}
}
list.add(scAddSheep);
util.exportExcel(response, list, "羊只信息");
}

View File

@ -110,6 +110,9 @@ public class ScTransitionInfoController extends BaseController {
@PutMapping("/approve")
public AjaxResult approveScTransitionInfo(@RequestBody ScTransitionInfo scTransitionInfo) {
if ("转场转入".equals(scTransitionInfo.getEventType()) && scTransitionInfo.getSheepfoldId() == null) {
return AjaxResult.error("转场转入时接收羊舍ID不能为空");
}
int rows = scTransitionInfoService.approveScTransitionInfo(scTransitionInfo);
return toAjax(rows);
}

View File

@ -68,6 +68,11 @@ public class ScAddSheep extends BaseEntity {
@Excel(name = "品种")
private String varietyName;
/** 羊只类别 */
private Long typeId;
@Excel(name = "羊只类型")
private String typeName;
/** 入群日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "入群日期", dateFormat = "yyyy-MM-dd")

View File

@ -27,8 +27,20 @@ public class ScChangeComment extends BaseEntity {
* 羊只id
*/
private String sheepId;
@Excel(name = "管理耳号")
private String manageTags;
/** 羊舍 */
private Long sheepfoldId;
@Excel(name = "羊舍")
private String sheepfoldName;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/**
* 新备注
*/

View File

@ -28,6 +28,15 @@ public class ScChangeEar extends BaseEntity
@Excel(name = "管理耳号")
private String manageTags;
/** 羊舍 */
private Long sheepfoldId;
@Excel(name = "羊舍")
private String sheepfoldName;
/** 事件类型(改管理耳号/改电子耳号) */
@Excel(name = "事件类型")
private String eventType;
/** 选择更改耳号类型0电子耳号1管理耳号 */
@Excel(name = "耳号类型", readConverterExp = "0=电子耳号,1=管理耳号")
private Integer earType;

View File

@ -29,6 +29,17 @@ public class ScChangeVariety extends BaseEntity
@Excel(name = "耳号")
private String manageTags;
/** 羊舍 */
private Long sheepfoldId;
@Excel(name = "羊舍")
private String sheepfoldName;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/** 原品种 */
@Excel(name = "原品种")
private String varietyOld;
@ -41,10 +52,5 @@ public class ScChangeVariety extends BaseEntity
@Excel(name = "备注")
private String comment;
/** 创建日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTime;
}

View File

@ -30,6 +30,14 @@ public class ScTransGroup extends BaseEntity {
@Excel(name = "耳号")
private String manageTags;
/**
* 事件类型1-围产转群2-普通转群3-育肥转群4-预售转群
*/
private Integer eventType;
@Excel(name = "事件类型")
private String eventTypeText;
/**
* 转入羊舍
*/
@ -40,18 +48,19 @@ public class ScTransGroup extends BaseEntity {
*/
private String foldFrom;
/**
* 羊只类型
*/
private Integer sheepTypeId;
@Excel(name = "羊只类型")
private String sheepTypeName;
/**
* 转出羊舍名称
*/
@Excel(name = "转出羊舍")
private String foldFromName;
/**
* 羊只类型ID
*/
private Integer sheepTypeId;
// 羊只类型名称
private String sheepTypeName;
/**
* 转入羊舍名称
*/
@ -77,6 +86,9 @@ public class ScTransGroup extends BaseEntity {
@Excel(name = "转群原因")
private String reasonText;
/** 转群日期 */
@Excel(name = "转群日期")
private String transDate;
/**
* 技术员
*/

View File

@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import java.time.LocalDate;
/**
* 转场对象 sc_transition_info
*
@ -27,9 +29,27 @@ public class ScTransitionInfo extends BaseEntity {
* 羊只id
*/
private Integer sheepId;
@Excel(name = "耳号")
private String manageTags;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/**
* 转场类型
*/
private Integer transType;
@Excel(name = "转场类型")
private String transTypeText;
/** 转场日期 */
@Excel(name = "转场日期")
private LocalDate transitionDate;
/**
* 品种id
*/
@ -54,16 +74,9 @@ public class ScTransitionInfo extends BaseEntity {
private String transFrom;
/**
* 转场类型
* 接收羊舍
*/
private Integer transType;
/**
* 转场类型名称 只用于导出
*/
@Excel(name = "转场类型")
private String transTypeText;
private Long sheepfoldId;
/**
* 技术员
*/
@ -76,6 +89,7 @@ public class ScTransitionInfo extends BaseEntity {
private Integer status;
@Excel(name = "状态")
private String statusText;
/**
* 备注
*/

View File

@ -7,15 +7,15 @@ import org.apache.ibatis.annotations.Param;
/**
* 转场Mapper接口
*
*
* @author ruoyi
* @date 2025-07-10
*/
public interface ScTransitionInfoMapper
public interface ScTransitionInfoMapper
{
/**
* 查询转场
*
*
* @param id 转场主键
* @return 转场
*/
@ -23,7 +23,7 @@ public interface ScTransitionInfoMapper
/**
* 查询转场列表
*
*
* @param scTransitionInfo 转场
* @return 转场集合
*/
@ -31,7 +31,7 @@ public interface ScTransitionInfoMapper
/**
* 新增转场
*
*
* @param scTransitionInfo 转场
* @return 结果
*/
@ -39,7 +39,7 @@ public interface ScTransitionInfoMapper
/**
* 修改转场
*
*
* @param scTransitionInfo 转场
* @return 结果
*/
@ -47,7 +47,7 @@ public interface ScTransitionInfoMapper
/**
* 删除转场
*
*
* @param id 转场主键
* @return 结果
*/
@ -55,7 +55,7 @@ public interface ScTransitionInfoMapper
/**
* 批量删除转场
*
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
@ -63,4 +63,5 @@ public interface ScTransitionInfoMapper
//批量转场
int insertScTransitionInfoBatch(@Param("list") List<ScTransitionInfo> transitionInfoList);
}

View File

@ -70,4 +70,5 @@ public interface IScTransitionInfoService {
//审批转场
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo);
}

View File

@ -2,7 +2,9 @@ package com.zhyc.module.produce.manage_sheep.service.impl;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.base.domain.BasSheepType;
import com.zhyc.module.base.mapper.BasSheepVarietyMapper;
import com.zhyc.module.base.service.IBasSheepTypeService;
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
import com.zhyc.module.produce.manage_sheep.mapper.ScAddSheepMapper;
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
@ -32,6 +34,8 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
@Autowired
private BasSheepVarietyMapper basSheepVarietyMapper;
@Autowired
private IBasSheepTypeService basSheepTypeService;
//新增
@Override
@Transactional(rollbackFor = Exception.class)
@ -64,7 +68,10 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
bs.setComment(scAddSheep.getComment());
bs.setCreateBy(scAddSheep.getCreateBy());
bs.setCreateTime(new Date());
if (scAddSheep.getTypeId() != null) {
bs.setTypeId(scAddSheep.getTypeId().longValue());
}
bs.setStatusId(1L);
basSheepService.insertBasSheep(bs);
return true;
}
@ -101,7 +108,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
for (int i = 0; i < list.size(); i++) {
ScAddSheep sheep = list.get(i);
try {
// 处理品种名称转换为品种ID
if (StringUtils.isNotBlank(sheep.getVarietyName())) {
Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName());
if (varietyId == null) {
@ -122,7 +128,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
// 处理羊舍名称转换为羊舍ID
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
DaSheepfold param = new DaSheepfold();
param.setSheepfoldName(sheep.getSheepfoldNameExcel());
@ -139,7 +144,23 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
sheep.setSheepfold(foldList.get(0).getId().intValue());
}
// 校验耳号是否为空
if (StringUtils.isNotBlank(sheep.getTypeName())) {
BasSheepType typeQuery = new BasSheepType();
typeQuery.setName(sheep.getTypeName().trim());
List<BasSheepType> typeList = basSheepTypeService.selectBasSheepTypeList(typeQuery);
if (typeList == null || typeList.isEmpty()) {
failure++;
failureMsg.append("<br/>第")
.append(i + 1)
.append("行:羊只类型名称不存在【")
.append(sheep.getTypeName())
.append("");
continue;
}
sheep.setTypeId(typeList.get(0).getId().longValue());
}
if (StringUtils.isBlank(sheep.getEarNumber())) {
failure++;
failureMsg.append("<br/>第")
@ -148,7 +169,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
// 核心校验判断羊只基本信息表中是否存在未删除的同名耳号
BasSheep existSheep = basSheepService.selectBasSheepByManageTags(sheep.getEarNumber().trim());
if (existSheep != null) {
failure++;
@ -160,7 +180,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue;
}
// 执行导入新增或更新
if (updateSupport && sheep.getId() != null) {
sheep.setUpdateBy(operName);
updateScAddSheep(sheep);

View File

@ -31,6 +31,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
private BasSheepMapper basSheepMapper;
@Autowired
private IBasSheepService basSheepService;
/**
* 查询转群记录
*
@ -42,6 +43,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
ScTransGroup group = scTransGroupMapper.selectScTransGroupById(id);
group.setReasonText(convertReason(group.getReason()));
group.setStatusText(convertStatus(group.getStatus()));
group.setEventTypeText(convertEventType(group.getEventType()));
return group;
}
@ -58,6 +60,7 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
list.forEach(group -> {
group.setReasonText(convertReason(group.getReason()));
group.setStatusText(convertStatus(group.getStatus()));
group.setEventTypeText(convertEventType(group.getEventType()));
});
return list;
}
@ -177,4 +180,18 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
return statusMap.getOrDefault(statusCode, "未知状态");
}
/**
* 转换事件类型1-围产转群2-普通转群3-育肥转群4-预售转群
*/
private String convertEventType(Integer eventType) {
if (eventType == null) {
return "未知";
}
Map<Integer, String> eventTypeMap = new HashMap<>();
eventTypeMap.put(1, "围产转群");
eventTypeMap.put(2, "普通转群");
eventTypeMap.put(3, "育肥转群");
eventTypeMap.put(4, "预售转群");
return eventTypeMap.getOrDefault(eventType, "未知");
}
}

View File

@ -127,8 +127,16 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
@Override
@Transactional(rollbackFor = Exception.class)
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo) {
// 1. 查询当前记录的原始状态
ScTransitionInfo existing = scTransitionInfoMapper.selectScTransitionInfoById(scTransitionInfo.getId());
if (existing == null) {
throw new RuntimeException("转场记录不存在");
}
// 2. 校验状态仅允许审批待审批的记录
if (existing.getStatus() != 0) {
throw new RuntimeException("该记录已完成审批,无法重复操作");
}
int rows = scTransitionInfoMapper.updateScTransitionInfo(scTransitionInfo);
if (rows > 0 && scTransitionInfo.getStatus() == 1) {
updateSheepRanch(scTransitionInfo);
}
@ -157,6 +165,12 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
}
Long targetRanchId = matchedRanch.get().getId();
//获取接收羊舍
Long targetSheepfoldId = transitionInfo.getSheepfoldId();
if ("转场转入".equals(transitionInfo.getEventType()) && targetSheepfoldId == null) {
throw new RuntimeException("转场转入时,接收羊舍不能为空");
}
String manageTags = transitionInfo.getManageTags();
if (StringUtils.isBlank(manageTags)) {
throw new RuntimeException("耳号不能为空");
@ -172,6 +186,9 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService
BasSheep updateSheep = new BasSheep();
updateSheep.setId(sheep.getId());
updateSheep.setRanchId(targetRanchId);
if ("转场转入".equals(transitionInfo.getEventType())) {
updateSheep.setSheepfoldId(targetSheepfoldId);
}
basSheepMapper.updateBasSheep(updateSheep);
}
}

View File

@ -31,6 +31,12 @@ public class ScCastrate extends BaseEntity {
@Excel(name = "耳号")
private String manageTags;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/**
* 羊舍id
*/

View File

@ -24,10 +24,15 @@ public class ScFixHoof extends BaseEntity
/** 羊只id */
private Integer sheepId;
/** 管理耳号(仅用于接收参数/返回视图) */
@Excel(name = "管理耳号")
private String manageTags;
/**
* 事件类型
*/
@Excel(name = "事件类型")
private String eventType;
/** 羊舍id */
private Integer sheepfold;

View File

@ -328,7 +328,7 @@
SELECT COUNT(*)
FROM bas_sheep
WHERE manage_tags = #{tag}
AND s.is_delete = 0
AND is_delete = 0
</select>
<select id="existsByElectronicTag" resultType="int">

View File

@ -18,6 +18,8 @@
<result property="parity" column="parity"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="typeId" column="type_id"/>
<result property="typeName" column="type_name"/>
<result property="joinDate" column="join_date"/>
<result property="comment" column="comment"/>
<result property="technician" column="technician"/>
@ -29,10 +31,12 @@
SELECT
sas.*,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName
bv.variety AS varietyName,
st.type_name AS typeName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
<where>
<if test="earNumber != null and earNumber != ''">
AND sas.ear_number LIKE CONCAT('%', #{earNumber}, '%')
@ -43,6 +47,9 @@
<if test="varietyId != null">
AND sas.variety_id = #{varietyId}
</if>
<if test="typeId != null">
AND sas.type_id = #{typeId}
</if>
</where>
</select>
@ -55,10 +62,10 @@
<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,
gender, parity, variety_id, type_id, join_date, comment, technician,
create_by, create_time)
VALUES (#{earNumber}, #{sheepfold}, #{father}, #{mother}, #{bornWeight},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{joinDate},
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{typeId}, #{joinDate},
#{comment}, #{technician}, #{createBy}, #{createTime})
</insert>
@ -74,6 +81,7 @@
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
type_id = #{typeId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},

View File

@ -8,6 +8,8 @@
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="sheepfoldName" column="sheepfold_name"/>
<result property="eventType" column="event_type"/>
<result property="newComment" column="new_comment"/>
<result property="oldComment" column="old_comment"/>
<result property="createBy" column="create_by"/>
@ -17,13 +19,16 @@
<sql id="selectScChangeCommentVo">
select scc.id,
scc.sheep_id,
bs.manage_tags as manage_tags,
bs.manage_tags as manage_tags,
sf.sheepfold_name as sheepfold_name,
'改备注' as event_type,
scc.new_comment,
scc.old_comment,
scc.create_by,
scc.create_time
from sc_change_comment scc
left join bas_sheep bs on scc.sheep_id = bs.id
left join da_sheepfold sf on bs.sheepfold_id = sf.id
</sql>
<select id="selectScChangeCommentList" parameterType="ScChangeComment" resultMap="ScChangeCommentResult">
@ -32,6 +37,7 @@
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
<if test="newComment != null and newComment != ''">
and scc.new_comment like concat('%', #{newComment}, '%')
</if>

View File

@ -8,6 +8,8 @@
<result property="id" column="sce_id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="sheepfoldName" column="sheepfold_name"/>
<result property="eventType" column="event_type"/>
<result property="earType" column="ear_type"/>
<result property="newTag" column="newTag"/>
<result property="oldTag" column="oldTag"/>
@ -20,6 +22,12 @@
select sce.id as sce_id,
sce.sheep_id,
bs.manage_tags as manage_tags,
sf.sheepfold_name as sheepfold_name,
case
when sce.ear_type = 0 then '改电子耳号'
when sce.ear_type = 1 then '改管理耳号'
else ''
end as event_type,
sce.ear_type,
sce.newTag,
sce.oldTag as oldTag,
@ -28,6 +36,7 @@
sce.create_time
from sc_change_ear sce
LEFT JOIN bas_sheep bs ON sce.sheep_id = bs.id
LEFT JOIN da_sheepfold sf ON bs.sheepfold_id = sf.id
</sql>
<select id="selectScChangeEarList" parameterType="ScChangeEar" resultMap="ScChangeEarResult">
@ -37,6 +46,10 @@
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
</if>
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
<if test="sheepfoldName != null and sheepfoldName != ''">
and sf.sheepfold_name LIKE CONCAT('%', #{sheepfoldName}, '%')
</if>
<if test="earType != null ">and sce.ear_type = #{earType}</if>
<if test="newTag != null and newTag != ''">
and sce.newTag LIKE CONCAT('%', #{newTag}, '%')

View File

@ -8,6 +8,8 @@
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manage_tags"/>
<result property="sheepfoldName" column="sheepfold_name"/>
<result property="eventType" column="event_type"/>
<result property="varietyOld" column="variety_old"/>
<result property="varietyNew" column="variety_new"/>
<result property="comment" column="comment"/>
@ -18,7 +20,9 @@
<sql id="selectScChangeVarietyVo">
select scv.id,
scv.sheep_id,
bs.manage_tags as manage_tags,
bs.manage_tags as manage_tags,
sf.sheepfold_name as sheepfold_name,
'改品种' as event_type,
scv.variety_old,
scv.variety_new,
scv.comment,
@ -26,6 +30,7 @@
scv.create_time
from sc_change_variety scv
left join bas_sheep bs on scv.sheep_id = bs.id
left join da_sheepfold sf on bs.sheepfold_id = sf.id
</sql>
<select id="selectScChangeVarietyList" parameterType="ScChangeVariety" resultMap="ScChangeVarietyResult">
@ -35,6 +40,7 @@
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="sheepfoldId != null">and bs.sheepfold_id = #{sheepfoldId}</if>
<if test="varietyOld != null and varietyOld != ''">
and scv.variety_old like concat('%', #{varietyOld}, '%')
</if>

View File

@ -25,18 +25,22 @@
SELECT tg.id,
tg.sheep_id,
s.manage_tags AS manageTags,
tg.event_type AS eventType,
tg.trans_date AS transDate,
tg.fold_to,
tg.fold_from,
tg.reason,
tg.variety_id,
bv.variety AS varietyName,
tg.technician,
st.id AS sheepTypeId,
st.name AS sheepTypeName,
tg.status,
tg.comment,
tg.create_by,
tg.create_time,
sf_from.sheepfold_name AS foldFromName,
sf_to.sheepfold_name AS foldToName,
tg.technician,
st.id AS sheepTypeId,
st.name AS sheepTypeName
FROM sc_trans_group tg
@ -54,10 +58,15 @@
<if test="manageTags != null and manageTags != ''">
and s.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="eventType != null">and tg.event_type = #{eventType}</if>
<if test="params.beginTransDate != null and params.beginTransDate != '' and params.endTransDate != null and params.endTransDate != ''">
and tg.trans_date between #{params.beginTransDate} and #{params.endTransDate}
</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="status != null">and status = #{status}</if>
<if test="varietyId != null">and tg.variety_id = #{varietyId}</if>
<if test="sheepTypeId != null">and st.id = #{sheepTypeId}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and tg.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
@ -75,6 +84,8 @@
insert into sc_trans_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sheepId != null">sheep_id,</if>
<if test="eventType != null">event_type,</if>
<if test="transDate != null and transDate != ''">trans_date,</if>
<if test="foldTo != null and foldTo != ''">fold_to,</if>
<if test="foldFrom != null and foldFrom != ''">fold_from,</if>
<if test="varietyId != null">variety_id,</if>
@ -87,6 +98,8 @@
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sheepId != null">#{sheepId},</if>
<if test="eventType != null">#{eventType},</if>
<if test="transDate != null and transDate != ''">#{transDate},</if>
<if test="foldTo != null and foldTo != ''">#{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">#{foldFrom},</if>
<if test="varietyId != null">#{varietyId},</if>
@ -103,6 +116,8 @@
update sc_trans_group
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="eventType != null">event_type = #{eventType},</if>
<if test="transDate != null and transDate != ''">trans_date = #{transDate},</if>
<if test="foldTo != null and foldTo != ''">fold_to = #{foldTo},</if>
<if test="foldFrom != null and foldFrom != ''">fold_from = #{foldFrom},</if>
<if test="varietyId != null">variety_id = #{varietyId},</if>

View File

@ -6,12 +6,14 @@
<resultMap type="com.zhyc.module.produce.manage_sheep.domain.ScTransitionInfo" id="ScTransitionInfoResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="eventType" column="event_type"/>
<result property="varietyId" column="variety_id"/>
<result property="varietyName" column="varietyName"/>
<result property="transTo" column="trans_to"/>
<result property="transFrom" column="trans_from"/>
<result property="transType" column="trans_type"/>
<result property="transTypeText" column="transTypeText"/>
<result property="transitionDate" column="transition_date"/>
<result property="technician" column="technician"/>
<result property="status" column="status"/>
<result property="comment" column="comment"/>
@ -21,20 +23,22 @@
<sql id="selectScTransitionInfoVo">
SELECT t.*,
bv.variety AS varietyName,
bs.manage_tags AS manageTags,
bv.variety AS varietyName,
bs.manage_tags AS manageTags,
t.event_type AS eventType,
t.transition_date AS transitionDate,
CASE t.trans_type
WHEN 0 THEN '内部调拨'
WHEN 1 THEN '内部销售'
WHEN 2 THEN '育肥调拨'
ELSE '未知'
END AS transTypeText,
END AS transTypeText,
CASE t.status
WHEN 0 THEN '待审批'
WHEN 1 THEN '已通过'
WHEN 2 THEN '已驳回'
ELSE '未知状态'
END AS statusText
END AS statusText
FROM sc_transition_info t
LEFT JOIN bas_sheep bs ON t.sheep_id = bs.id
LEFT JOIN bas_sheep_variety bv ON bs.variety_id = bv.id
@ -47,6 +51,14 @@
<if test="manageTags != null and manageTags != ''">
and bs.manage_tags LIKE CONCAT('%', #{manageTags}, '%')
</if>
<if test="eventType != null and eventType != ''">
and t.event_type = #{eventType}
</if>
<if test="transType != null">and t.trans_type = #{transType}</if>
<if test="params.beginTransitionDate != null and params.beginTransitionDate != ''
and params.endTransitionDate != null and params.endTransitionDate != ''">
and t.transition_date between #{params.beginTransitionDate} and #{params.endTransitionDate}
</if>
<if test="varietyId != null">and bs.variety_id = #{varietyId}</if>
<if test="transTo != null and transTo != ''">and trans_to = #{transTo}</if>
<if test="transFrom != null and transFrom != ''">and trans_from = #{transFrom}</if>
@ -69,7 +81,9 @@
<if test="varietyId != null">variety_id,</if>
<if test="transTo != null and transTo != ''">trans_to,</if>
<if test="transFrom != null and transFrom != ''">trans_from,</if>
<if test="eventType != null and eventType != ''">event_type,</if>
<if test="transType != null">trans_type,</if>
<if test="transitionDate != null">transition_date,</if>
<if test="technician != null and technician != ''">technician,</if>
<if test="status != null">status,</if>
<if test="comment != null">comment,</if>
@ -81,7 +95,9 @@
<if test="varietyId != null">#{varietyId},</if>
<if test="transTo != null and transTo != ''">#{transTo},</if>
<if test="transFrom != null and transFrom != ''">#{transFrom},</if>
<if test="eventType != null and eventType != ''">#{eventType},</if>
<if test="transType != null">#{transType},</if>
<if test="transitionDate != null">#{transitionDate},</if>
<if test="technician != null and technician != ''">#{technician},</if>
<if test="status != null">#{status},</if>
<if test="comment != null">#{comment},</if>
@ -93,13 +109,13 @@
<insert id="insertScTransitionInfoBatch">
INSERT INTO sc_transition_info (
sheep_id, variety_id, trans_to, trans_from,
trans_type, technician, status, comment,
event_type,trans_type, transition_date, technician, status, comment,
create_by, create_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom},
#{item.transType}, #{item.technician}, #{item.status}, #{item.comment},
#{item.sheepId}, #{item.varietyId}, #{item.transTo}, #{item.transFrom}, #{item.eventType},
#{item.transType},#{item.transitionDate}, #{item.technician}, #{item.status}, #{item.comment},
#{item.createBy}, now()
)
</foreach>
@ -110,9 +126,12 @@
<trim prefix="SET" suffixOverrides=",">
<if test="sheepId != null">sheep_id = #{sheepId},</if>
<if test="varietyId != null">variety_id = #{varietyId},</if>
<if test="sheepfoldId != null">sheepfold_id = #{sheepfoldId},</if>
<if test="transTo != null and transTo != ''">trans_to = #{transTo},</if>
<if test="transFrom != null and transFrom != ''">trans_from = #{transFrom},</if>
<if test="eventType != null and eventType != ''">event_type = #{eventType},</if>
<if test="transType != null">trans_type = #{transType},</if>
<if test="transitionDate != null">transition_date = #{transitionDate},</if>
<if test="technician != null and technician != ''">technician = #{technician},</if>
<if test="status != null">status = #{status},</if>
<if test="comment != null">comment = #{comment},</if>

View File

@ -4,10 +4,11 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.other.mapper.ScCastrateMapper">
<resultMap type="ScCastrate" id="ScCastrateResult">
<resultMap type="com.zhyc.module.produce.other.domain.ScCastrate" id="ScCastrateResult">
<result property="id" column="id"/>
<result property="sheepId" column="sheep_id"/>
<result property="manageTags" column="manageTags"/>
<result property="eventType" column="event_type"/>
<result property="sheepfold" column="sheepfold"/>
<result property="sheepfoldName" column="sheepfoldName"/>
<result property="varietyId" column="variety_id"/>
@ -22,6 +23,7 @@
select sc.id,
sc.sheep_id,
bs.manage_tags as manageTags,
'去势' as event_type,
bs.sheepfold_id as sheepfold,
sf.sheepfold_name as sheepfoldName,
bs.variety_id as varietyId,

View File

@ -4,9 +4,10 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.produce.other.mapper.ScFixHoofMapper">
<resultMap type="ScFixHoof" id="ScFixHoofResult">
<resultMap type="com.zhyc.module.produce.other.domain.ScFixHoof" id="ScFixHoofResult">
<result property="id" column="id"/>
<result property="manageTags" column="manageTags"/>
<result property="eventType" column="event_type"/>
<result property="sheepfold" column="sheepfold"/>
<result property="varietyId" column="variety_id"/>
<result property="sheepfoldName" column="sheepfoldName"/>
@ -19,6 +20,7 @@
<sql id="selectScFixHoofVo">
select fh.id,
bs.manage_tags as manageTags,
'修蹄' as event_type,
bs.sheepfold_id as sheepfold,
sf.sheepfold_name as sheepfoldName,
bs.variety_id as varietyId,