优化了死亡模块,修改状态在群不在群
This commit is contained in:
parent
357595b6f4
commit
d9d489c1a0
@ -70,11 +70,20 @@ public interface ScSheepDeathMapper
|
||||
public int deleteScSheepDeathByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 更新羊只状态
|
||||
* 更新羊只繁育状态
|
||||
*
|
||||
* @param sheepId 羊只ID
|
||||
* @param status 状态
|
||||
* @param status 繁育状态
|
||||
* @return 更新结果
|
||||
*/
|
||||
public int updateSheepFileStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 新增:更新羊只在群状态
|
||||
*
|
||||
* @param sheepId 羊只ID
|
||||
* @param status 在群状态(1-在群,2-不在群)
|
||||
* @return 更新结果
|
||||
*/
|
||||
public int updateSheepStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
|
||||
}
|
||||
@ -111,7 +111,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) {
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null);
|
||||
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
scSheepDeath.setSheepId(sheepId);
|
||||
|
||||
// 插入死淘记录后,同时更新羊只在群状态为"不在群"(字典值为2)
|
||||
if (sheepId != null) {
|
||||
scSheepDeathMapper.updateSheepStatus(sheepId, "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +138,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) {
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setSheepId(sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null);
|
||||
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
scSheepDeath.setSheepId(sheepId);
|
||||
|
||||
// 修改死淘记录时,同时更新羊只在群状态为"不在群"(字典值为2)
|
||||
if (sheepId != null) {
|
||||
scSheepDeathMapper.updateSheepStatus(sheepId, "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +161,15 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
@Override
|
||||
public int deleteScSheepDeathByIds(Long[] ids)
|
||||
{
|
||||
// 可选:删除死淘记录前,将对应羊只在群状态改回"在群"
|
||||
for (Long id : ids) {
|
||||
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
if (scSheepDeath != null && scSheepDeath.getSheepId() != null) {
|
||||
// 恢复羊只在群状态为"在群"(字典值为1)
|
||||
scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1");
|
||||
}
|
||||
}
|
||||
|
||||
return scSheepDeathMapper.deleteScSheepDeathByIds(ids);
|
||||
}
|
||||
|
||||
@ -161,6 +182,13 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
@Override
|
||||
public int deleteScSheepDeathById(Long id)
|
||||
{
|
||||
// 可选:删除死淘记录前,将对应羊只在群状态改回"在群"
|
||||
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
if (scSheepDeath != null && scSheepDeath.getSheepId() != null) {
|
||||
// 恢复羊只在群状态为"在群"(字典值为1)
|
||||
scSheepDeathMapper.updateSheepStatus(scSheepDeath.getSheepId(), "1");
|
||||
}
|
||||
|
||||
return scSheepDeathMapper.deleteScSheepDeathById(id);
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据管理耳号查询sheep_file视图信息 - 修复:删除不存在的status字段 -->
|
||||
<!-- 根据管理耳号查询sheep_file视图信息 -->
|
||||
<select id="selectSheepFileByManageTags" parameterType="String" resultType="java.util.Map">
|
||||
select
|
||||
id as sheepId,
|
||||
@ -145,7 +145,7 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 更新羊只状态 - 根据实际的sheep_file表结构调整字段名 -->
|
||||
<!-- 更新羊只繁育状态 - 保留原有功能 -->
|
||||
<update id="updateSheepFileStatus">
|
||||
UPDATE sheep_file
|
||||
SET breed = #{status},
|
||||
@ -154,4 +154,13 @@
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
<!-- 新增:更新羊只在群状态 -->
|
||||
<update id="updateSheepStatus">
|
||||
UPDATE sheep_file
|
||||
SET status = #{status},
|
||||
update_time = NOW()
|
||||
WHERE id = #{sheepId}
|
||||
AND is_delete = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user