diff --git a/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java b/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java index 92c683b..cc608df 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java +++ b/zhyc-module/src/main/java/com/zhyc/module/base/domain/BasSheep.java @@ -103,6 +103,14 @@ public class BasSheep extends BaseEntity @Excel(name = "母号id") private Long motherId; + /** 外祖父耳号 */ + @Excel(name = "外祖父") + private String grandpa; + + /** 外祖母耳号 */ + @Excel(name = "外祖母") + private String grandma; + /** 受体id */ @Excel(name = "受体id") private Long receptorId; diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java index 6d99be7..a909a90 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/domain/ScAddSheep.java @@ -56,6 +56,25 @@ public class ScAddSheep extends BaseEntity { */ @Excel(name = "母号") private String mother; + + /** + * 外祖父耳号 + */ + @Excel(name = "外祖父") + private String grandpa; + + /** + * 外祖母耳号 + */ + @Excel(name = "外祖母") + private String grandma; + + /** + * 出生体重 + */ + @Excel(name = "出生体重") + private BigDecimal bornWeight; + /** * 断奶体重(仅接收,不入库) */ @@ -63,11 +82,7 @@ public class ScAddSheep extends BaseEntity { private BigDecimal weaningWeight; private String createBy; private Date createTime; - /** - * 出生体重 - */ - @Excel(name = "出生体重") - private BigDecimal bornWeight; + /** * 出生日期 @@ -103,7 +118,6 @@ public class ScAddSheep extends BaseEntity { * 羊只类别 */ private Long typeId; - @Excel(name = "羊只类型") private String typeName; /** @@ -116,13 +130,11 @@ public class ScAddSheep extends BaseEntity { /** * 备注 */ - @Excel(name = "备注") private String comment; /** * 技术员 */ - @Excel(name = "技术员") private String technician; diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java index 23cc7ba..23949e0 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScAddSheepServiceImpl.java @@ -52,7 +52,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { throw new ServiceException("添加失败,耳号已存在"); } - // userId 和 deptId 已在 Controller 中设置,直接插入 boolean ok = scAddSheepMapper.insert(scAddSheep) > 0; if (!ok) return false; @@ -60,10 +59,28 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { bs.setManageTags(scAddSheep.getEarNumber()); bs.setRanchId(scAddSheep.getRanchId().longValue()); bs.setSheepfoldId(scAddSheep.getSheepfold().longValue()); - bs.setFatherId(null); - bs.setMotherId(null); + if (StringUtils.isNotBlank(scAddSheep.getFather())) { + BasSheep fatherSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getFather().trim()); + if (fatherSheep == null) { + throw new ServiceException("父号【" + scAddSheep.getFather() + "】不存在"); + } + bs.setFatherId(fatherSheep.getId()); + } + if (StringUtils.isNotBlank(scAddSheep.getMother())) { + BasSheep motherSheep = basSheepService.selectBasSheepByManageTags(scAddSheep.getMother().trim()); + if (motherSheep == null) { + throw new ServiceException("母号【" + scAddSheep.getMother() + "】不存在"); + } + bs.setMotherId(motherSheep.getId()); + } + bs.setGrandpa(scAddSheep.getGrandpa()); + bs.setGrandma(scAddSheep.getGrandma()); bs.setBirthWeight(scAddSheep.getBornWeight().longValue()); - bs.setWeaningWeight(scAddSheep.getWeaningWeight().longValue()); + if (scAddSheep.getWeaningWeight() != null) { + bs.setWeaningWeight(scAddSheep.getWeaningWeight().longValue()); + } else { + bs.setWeaningWeight(null); + } bs.setSource(String.valueOf(2)); bs.setBirthday(scAddSheep.getBirthday()); bs.setGender(scAddSheep.getGender().longValue()); @@ -88,7 +105,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { //查询 @Override - @DataScope(deptAlias = "sas", userAlias = "sas") // sas 是 sc_add_sheep 的别名 + @DataScope(deptAlias = "sas", userAlias = "sas") public List selectScAddSheepList(ScAddSheep scAddSheep) { return scAddSheepMapper.selectScAddSheepList(scAddSheep); } @@ -208,7 +225,23 @@ public class ScAddSheepServiceImpl implements IScAddSheepService { .append("】"); continue; } + if (StringUtils.isNotBlank(sheep.getFather())) { + BasSheep father = basSheepService.selectBasSheepByManageTags(sheep.getFather().trim()); + if (father == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:父号不存在【").append(sheep.getFather()).append("】"); + continue; + } + } + if (StringUtils.isNotBlank(sheep.getMother())) { + BasSheep mother = basSheepService.selectBasSheepByManageTags(sheep.getMother().trim()); + if (mother == null) { + failure++; + failureMsg.append("
第").append(i + 1).append("行:母号不存在【").append(sheep.getMother()).append("】"); + continue; + } + } // 数据分离:设置用户和部门 sheep.setUserId(userId); sheep.setDeptId(deptId); diff --git a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java index 4c73612..719d2c4 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/produce/manage_sheep/service/impl/ScTransitionInfoServiceImpl.java @@ -235,7 +235,7 @@ public class ScTransitionInfoServiceImpl implements IScTransitionInfoService BasSheep upd = new BasSheep(); upd.setId(sheep.getId()); upd.setRanchId(targetRanchId); - upd.setSheepfoldId(targetSheepfoldId); // 真正换舍 + upd.setSheepfoldId(targetSheepfoldId); basSheepMapper.updateBasSheep(upd); } } diff --git a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml index 514e9a4..0ca050e 100644 --- a/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml +++ b/zhyc-module/src/main/resources/mapper/produce/manage_sheep/ScAddSheepMapper.xml @@ -12,6 +12,8 @@ + + @@ -36,6 +38,8 @@ sas.ranch_id, sas.father, sas.mother, + sas.grandpa, + sas.grandma, sas.born_weight, sas.birthday, sas.gender, @@ -90,6 +94,8 @@ ranch_id, father, mother, + grandpa, + grandma, born_weight, birthday, gender, @@ -110,6 +116,8 @@ #{ranchId}, #{father}, #{mother}, + #{grandpa}, + #{grandma}, #{bornWeight}, #{birthday}, #{gender},