Compare commits

..

No commits in common. "2083325e40f2a5db42d26dfca3e60d4984b89013" and "58a79671a0a3289c8d329728ca647544adc74e14" have entirely different histories.

3 changed files with 13 additions and 31 deletions

View File

@ -78,6 +78,4 @@ public interface BasSheepMapper
//用于校验改耳号部分新管理/电子耳号 //用于校验改耳号部分新管理/电子耳号
int existsByManageTag(@Param("tag") String tag); int existsByManageTag(@Param("tag") String tag);
int existsByElectronicTag(@Param("tag") String tag); int existsByElectronicTag(@Param("tag") String tag);
} }

View File

@ -36,9 +36,9 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean insertScAddSheep(ScAddSheep scAddSheep) { public boolean insertScAddSheep(ScAddSheep scAddSheep) {
BasSheep existSheep =basSheepService.selectBasSheepByManageTags(scAddSheep.getEarNumber().trim()); ScAddSheep exist = scAddSheepMapper.selectByEarNumber(scAddSheep.getEarNumber());
if (existSheep != null) { if (exist != null) {
throw new ServiceException("添加失败,耳号已存在"); throw new ServiceException("添加失败,耳号重复");
} }
boolean ok = scAddSheepMapper.insert(scAddSheep) > 0; boolean ok = scAddSheepMapper.insert(scAddSheep) > 0;
@ -101,7 +101,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
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 {
// 处理品种名称转换为品种ID
if (StringUtils.isNotBlank(sheep.getVarietyName())) { if (StringUtils.isNotBlank(sheep.getVarietyName())) {
Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName()); Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName());
if (varietyId == null) { if (varietyId == null) {
@ -122,7 +121,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue; continue;
} }
// 处理羊舍名称转换为羊舍ID
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) { if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
DaSheepfold param = new DaSheepfold(); DaSheepfold param = new DaSheepfold();
param.setSheepfoldName(sheep.getSheepfoldNameExcel()); param.setSheepfoldName(sheep.getSheepfoldNameExcel());
@ -139,7 +137,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
sheep.setSheepfold(foldList.get(0).getId().intValue()); sheep.setSheepfold(foldList.get(0).getId().intValue());
} }
// 校验耳号是否为空
if (StringUtils.isBlank(sheep.getEarNumber())) { if (StringUtils.isBlank(sheep.getEarNumber())) {
failure++; failure++;
failureMsg.append("<br/>第") failureMsg.append("<br/>第")
@ -148,19 +145,17 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
continue; continue;
} }
// 核心校验判断羊只基本信息表中是否存在未删除的同名耳号 ScAddSheep exist = scAddSheepMapper.selectByEarNumber(sheep.getEarNumber());
BasSheep existSheep = basSheepService.selectBasSheepByManageTags(sheep.getEarNumber().trim()); if (exist != null) {
if (existSheep != null) {
failure++; failure++;
failureMsg.append("<br/>第") failureMsg.append("<br/>第")
.append(i + 1) .append(i + 1)
.append("行:耳号已存在且未删除") .append("行:耳号已存在")
.append(sheep.getEarNumber()) .append(sheep.getEarNumber())
.append(""); .append("");
continue; continue;
} }
// 执行导入新增或更新
if (updateSupport && sheep.getId() != null) { if (updateSupport && sheep.getId() != null) {
sheep.setUpdateBy(operName); sheep.setUpdateBy(operName);
updateScAddSheep(sheep); updateScAddSheep(sheep);

View File

@ -128,8 +128,7 @@
<if test="sourceDate != null ">and source_date = #{sourceDate}</if> <if test="sourceDate != null ">and source_date = #{sourceDate}</if>
<if test="sourceRanchId != null ">and source_ranch_id = #{sourceRanchId}</if> <if test="sourceRanchId != null ">and source_ranch_id = #{sourceRanchId}</if>
<if test="comment != null and comment != ''">and comment = #{comment}</if> <if test="comment != null and comment != ''">and comment = #{comment}</if>
<if test="isDelete == null">and is_delete = 0</if> <if test="isDelete != null ">and is_delete = #{isDelete}</if>
<if test="isDelete != null">and is_delete = #{isDelete}</if>
</where> </where>
</select> </select>
@ -152,24 +151,20 @@
bv.variety AS varietyName bv.variety AS varietyName
FROM bas_sheep s FROM bas_sheep s
LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id LEFT JOIN bas_sheep_variety bv ON s.variety_id = bv.id
WHERE s.manage_tags = #{manageTags} WHERE s.manage_tags = #{manageTags} LIMIT 1
AND s.is_delete = 0 LIMIT 1
</select> </select>
<select id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult"> <select id="selectBasSheepBySheepfold" parameterType="BasSheep" resultMap="BasSheepResult">
<include refid="selectBasSheepVo"/> <include refid="selectBasSheepVo"/>
<where> <where>
sheepfold_id = #{id} sheepfold_id = #{id}
and is_delete = 0
</where> </where>
</select> </select>
<select id="getSheepByRanchId" resultMap="BasSheepResult"> <select id="getSheepByRanchId" resultMap="BasSheepResult">
<include refid="selectBasSheepVo"/> SELECT *
<where> FROM bas_sheep
ranch_id = #{ranchId} WHERE ranch_id = #{ranchId}
and is_delete = 0
</where>
</select> </select>
<select id="selectBasSheepListByIds" parameterType="list" resultMap="BasSheepResult"> <select id="selectBasSheepListByIds" parameterType="list" resultMap="BasSheepResult">
@ -325,16 +320,10 @@
</delete> </delete>
<select id="existsByManageTag" resultType="int"> <select id="existsByManageTag" resultType="int">
SELECT COUNT(*) SELECT COUNT(*) FROM bas_sheep WHERE manage_tags = #{tag} AND is_delete = 0
FROM bas_sheep
WHERE manage_tags = #{tag}
AND s.is_delete = 0
</select> </select>
<select id="existsByElectronicTag" resultType="int"> <select id="existsByElectronicTag" resultType="int">
SELECT COUNT(*) SELECT COUNT(*) FROM bas_sheep WHERE electronic_tags = #{tag} AND is_delete = 0
FROM bas_sheep
WHERE electronic_tags = #{tag}
AND is_delete = 0
</select> </select>
</mapper> </mapper>