Merge remote-tracking branch 'origin/main'
# Conflicts: # zhyc-module/src/main/java/com/zhyc/module/produce/breed/service/impl/ScSheepDeathServiceImpl.java
This commit is contained in:
commit
357595b6f4
@ -66,6 +66,21 @@ public class SecurityUtils
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
**/
|
||||
public static String getNickName()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getUser().getNickName();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("获取用户昵称异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
package com.zhyc.module.base.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.common.core.domain.entity.SysDictData;
|
||||
import com.zhyc.common.utils.StringUtils;
|
||||
import com.zhyc.module.base.domain.BasGroupTreeVo;
|
||||
import com.zhyc.module.base.domain.BasSheepGroupMapping;
|
||||
import com.zhyc.module.base.domain.BasSheepGroupExportVo;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -22,6 +25,13 @@ import com.zhyc.common.core.page.TableDataInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
// 1. 引入若依字典工具
|
||||
import com.zhyc.common.utils.DictUtils;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 羊只分组关联Controller
|
||||
@ -33,6 +43,20 @@ import org.slf4j.LoggerFactory;
|
||||
@RequestMapping("/sheep_grouping/sheep_grouping")
|
||||
public class BasSheepGroupMappingController extends BaseController
|
||||
{
|
||||
|
||||
// 工具方法:LocalDateTime -> Date
|
||||
private Date toDate(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
if (obj instanceof Date) {
|
||||
return (Date) obj;
|
||||
}
|
||||
if (obj instanceof LocalDateTime) {
|
||||
return Date.from(((LocalDateTime) obj).atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
throw new IllegalArgumentException("不支持的日期类型:" + obj.getClass());
|
||||
}
|
||||
@Autowired
|
||||
private IBasSheepGroupMappingService basSheepGroupMappingService;
|
||||
|
||||
@ -73,16 +97,73 @@ public class BasSheepGroupMappingController extends BaseController
|
||||
/**
|
||||
* 导出羊只分组关联列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:export')")
|
||||
// @Log(title = "羊只分组关联", businessType = BusinessType.EXPORT)
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, BasSheepGroupMapping basSheepGroupMapping)
|
||||
// {
|
||||
// List<BasSheepGroupMapping> list = basSheepGroupMappingService.selectBasSheepGroupMappingList(basSheepGroupMapping);
|
||||
// ExcelUtil<BasSheepGroupMapping> util = new ExcelUtil<BasSheepGroupMapping>(BasSheepGroupMapping.class);
|
||||
// util.exportExcel(response, list, "羊只分组关联数据");
|
||||
// }
|
||||
@PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:export')")
|
||||
@Log(title = "羊只分组关联", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BasSheepGroupMapping basSheepGroupMapping)
|
||||
{
|
||||
List<BasSheepGroupMapping> list = basSheepGroupMappingService.selectBasSheepGroupMappingList(basSheepGroupMapping);
|
||||
ExcelUtil<BasSheepGroupMapping> util = new ExcelUtil<BasSheepGroupMapping>(BasSheepGroupMapping.class);
|
||||
util.exportExcel(response, list, "羊只分组关联数据");
|
||||
public void exportJoin(HttpServletResponse response,
|
||||
@RequestParam(required = false) Long sheepId,
|
||||
@RequestParam(required = false) Long groupId,
|
||||
@RequestParam(required = false) String bsManageTags) throws IOException {
|
||||
|
||||
// 1. 把前端传来的耳号字符串转 List
|
||||
List<String> earList = null;
|
||||
if (StringUtils.hasText(bsManageTags)) {
|
||||
earList = Arrays.asList(bsManageTags.split("[,,\\s]+"));
|
||||
}
|
||||
|
||||
// 2. 先查出来(这里返回 List<Map<String,Object>>)
|
||||
List<Map<String, Object>> list = basSheepGroupMappingService
|
||||
.selectBasSheepGroupMappingList(sheepId, groupId, earList);
|
||||
// 放在 stream 外面,避免每次都查缓存
|
||||
Map<String, String> genderMap = new HashMap<>();
|
||||
List<SysDictData> genderDict = DictUtils.getDictCache("sheep_gender");
|
||||
if (genderDict != null) {
|
||||
genderDict.forEach(d -> genderMap.put(d.getDictValue(), d.getDictLabel()));
|
||||
}
|
||||
// 3. Map → VO
|
||||
List<BasSheepGroupExportVo> voList = list.stream()
|
||||
.map(m -> {
|
||||
BasSheepGroupExportVo vo = new BasSheepGroupExportVo();
|
||||
vo.setGroupId(m.get("group_id") == null ? null : ((Number) m.get("group_id")).longValue());
|
||||
vo.setGroupName((String) m.get("group_name"));
|
||||
vo.setBsManageTags((String) m.get("bs_manage_tags"));
|
||||
vo.setVariety((String) m.get("variety"));
|
||||
vo.setFamily((String) m.get("family"));
|
||||
vo.setName((String) m.get("name"));
|
||||
vo.setGender(m.get("gender") == null ? null : ((Number) m.get("gender")).longValue());
|
||||
Long genderCode = m.get("gender") == null ? null : ((Number) m.get("gender")).longValue();
|
||||
vo.setGender(genderCode);
|
||||
vo.setGenderText(genderMap.get(String.valueOf(genderCode)));
|
||||
vo.setBirthday(toDate(m.get("birthday")));
|
||||
vo.setMonthAge(m.get("month_age") == null ? null : ((Number) m.get("month_age")).longValue());
|
||||
vo.setParity(m.get("parity") == null ? null : ((Number) m.get("parity")).longValue());
|
||||
vo.setBirthWeight(m.get("birth_weight") == null ? null : ((Number) m.get("birth_weight")).longValue());
|
||||
|
||||
vo.setWeaningWeight(m.get("weaning_weight") == null ? null : ((Number) m.get("weaning_weight")).longValue());
|
||||
vo.setCurrentWeight(m.get("current_weight") == null ? null : ((Number) m.get("current_weight")).longValue());
|
||||
vo.setBreed((String) m.get("breed"));
|
||||
vo.setFatherManageTags((String) m.get("father_manage_tags"));
|
||||
vo.setMotherManageTags((String) m.get("mother_manage_tags"));
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 4. 导出
|
||||
ExcelUtil<BasSheepGroupExportVo> util = new ExcelUtil<>(BasSheepGroupExportVo.class);
|
||||
util.exportExcel(response, voList, "羊只分组关联数据");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取羊只分组关联详细信息
|
||||
*/
|
||||
@ -144,5 +225,13 @@ public class BasSheepGroupMappingController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 树形分组下拉框
|
||||
*/
|
||||
@GetMapping("/group/tree")
|
||||
public AjaxResult groupTree() {
|
||||
return success(basSheepGroupMappingService.selectGroupTree());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -14,7 +14,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.common.utils.DictUtils;
|
||||
|
||||
/**
|
||||
* 羊舍管理Controller
|
||||
@ -119,4 +123,73 @@ public class DaSheepfoldController extends BaseController
|
||||
boolean exist = daSheepfoldService.checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo);
|
||||
return AjaxResult.success(exist);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('sheepfold_management:sheepfold_management:list')")
|
||||
@GetMapping("/seatMap")
|
||||
public AjaxResult seatMap() {
|
||||
List<DaSheepfold> flat = daSheepfoldService.selectDaSheepfoldList(new DaSheepfold());
|
||||
Map<Long, Map<String, Object>> tree = new LinkedHashMap<>();
|
||||
|
||||
for (DaSheepfold s : flat) {
|
||||
Long ranchId = s.getRanchId();
|
||||
Long typeId = s.getSheepfoldTypeId();
|
||||
String foldNo = s.getSheepfoldNo();
|
||||
String rowNo = s.getRowNo();
|
||||
String columns = s.getColumns();
|
||||
|
||||
// 翻译字典
|
||||
String ranchName = DictUtils.getDictLabel("da_ranch", String.valueOf(ranchId));
|
||||
String typeName = DictUtils.getDictLabel("bas_sheepfold_type", String.valueOf(typeId));
|
||||
|
||||
// 牧场
|
||||
Map<String, Object> ranch = tree.computeIfAbsent(ranchId, k -> {
|
||||
Map<String, Object> r = new LinkedHashMap<>();
|
||||
r.put("ranchId", k);
|
||||
r.put("ranchName", ranchName);
|
||||
r.put("types", new ArrayList<>());
|
||||
return r;
|
||||
});
|
||||
|
||||
// 类型
|
||||
Map<String, Object> type = ((List<Map<String, Object>>) ranch.get("types")).stream()
|
||||
.filter(t -> typeId.equals(t.get("typeId")))
|
||||
.findFirst()
|
||||
.orElseGet(() -> {
|
||||
Map<String, Object> t = new LinkedHashMap<>();
|
||||
t.put("typeId", typeId);
|
||||
t.put("typeName", typeName);
|
||||
t.put("folds", new ArrayList<>());
|
||||
((List<Map<String, Object>>) ranch.get("types")).add(t);
|
||||
return t;
|
||||
});
|
||||
|
||||
// 羊舍
|
||||
Map<String, Object> fold = ((List<Map<String, Object>>) type.get("folds")).stream()
|
||||
.filter(f -> foldNo.equals(f.get("foldNo")))
|
||||
.findFirst()
|
||||
.orElseGet(() -> {
|
||||
Map<String, Object> f = new LinkedHashMap<>();
|
||||
f.put("foldNo", foldNo);
|
||||
f.put("rows", new ArrayList<>());
|
||||
((List<Map<String, Object>>) type.get("folds")).add(f);
|
||||
return f;
|
||||
});
|
||||
|
||||
// 排
|
||||
Map<String, Object> row = ((List<Map<String, Object>>) fold.get("rows")).stream()
|
||||
.filter(r -> rowNo.equals(r.get("rowNo")))
|
||||
.findFirst()
|
||||
.orElseGet(() -> {
|
||||
Map<String, Object> newRow = new LinkedHashMap<>();
|
||||
newRow.put("rowNo", rowNo);
|
||||
newRow.put("columns", new ArrayList<>());
|
||||
((List<Map<String, Object>>) fold.get("rows")).add(newRow);
|
||||
return newRow;
|
||||
});
|
||||
|
||||
// 将列号添加到对应的行
|
||||
((List<String>) row.get("columns")).add(columns);
|
||||
}
|
||||
return success(new ArrayList<>(tree.values()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.zhyc.module.base.domain;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BasGroupTreeVo {
|
||||
private Long groupId;
|
||||
private String groupName;
|
||||
private Long parentId;
|
||||
private List<BasGroupTreeVo> children;
|
||||
}
|
||||
@ -0,0 +1,235 @@
|
||||
package com.zhyc.module.base.domain;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BasSheepGroupExportVo extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
private Long groupId;
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
/** 分组名称 */
|
||||
@Excel(name = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
/** 管理耳号 */
|
||||
@Excel(name = "耳号")
|
||||
private String bsManageTags;
|
||||
|
||||
/** 品种 */
|
||||
@Excel(name = "品种")
|
||||
private String variety;
|
||||
|
||||
/** 性别 */
|
||||
|
||||
private Long gender;
|
||||
|
||||
public String getGenderText() {
|
||||
return genderText;
|
||||
}
|
||||
|
||||
public void setGenderText(String genderText) {
|
||||
this.genderText = genderText;
|
||||
}
|
||||
|
||||
/* 性别文本,真正导出的列 */
|
||||
@Excel(name = "性别")
|
||||
private String genderText;
|
||||
|
||||
|
||||
/** 羊只类型 */
|
||||
@Excel(name = "羊只类型")
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/** 胎次 */
|
||||
@Excel(name = "胎次")
|
||||
private Long parity;
|
||||
|
||||
|
||||
/** 月龄 */
|
||||
@Excel(name = "月龄")
|
||||
private Long monthAge;
|
||||
|
||||
/** 繁殖状态 */
|
||||
@Excel(name = "繁殖状态")
|
||||
private String breed;
|
||||
|
||||
/** 出生体重 */
|
||||
@Excel(name = "出生体重")
|
||||
private Long birthWeight;
|
||||
|
||||
|
||||
/** 断奶体重 */
|
||||
@Excel(name = "断奶体重")
|
||||
private Long weaningWeight;
|
||||
|
||||
/** 当前体重 */
|
||||
@Excel(name = "当前体重")
|
||||
private Long currentWeight;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 父亲管理耳号 */
|
||||
@Excel(name = "父号")
|
||||
private String fatherManageTags;
|
||||
|
||||
|
||||
/** 母亲管理耳号 */
|
||||
@Excel(name = "母号")
|
||||
private String motherManageTags;
|
||||
|
||||
/** 家系 */
|
||||
@Excel(name = "家系")
|
||||
private String family;
|
||||
|
||||
|
||||
public String getBsManageTags() {
|
||||
return bsManageTags;
|
||||
}
|
||||
|
||||
public void setBsManageTags(String bsManageTags) {
|
||||
this.bsManageTags = bsManageTags;
|
||||
}
|
||||
|
||||
public String getVariety() {
|
||||
return variety;
|
||||
}
|
||||
|
||||
public void setVariety(String variety) {
|
||||
this.variety = variety;
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return family;
|
||||
}
|
||||
|
||||
public void setFamily(String family) {
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Long gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public Long getMonthAge() {
|
||||
return monthAge;
|
||||
}
|
||||
|
||||
public void setMonthAge(Long monthAge) {
|
||||
this.monthAge = monthAge;
|
||||
}
|
||||
|
||||
public Long getParity() {
|
||||
return parity;
|
||||
}
|
||||
|
||||
public void setParity(Long parity) {
|
||||
this.parity = parity;
|
||||
}
|
||||
|
||||
public Long getBirthWeight() {
|
||||
return birthWeight;
|
||||
}
|
||||
|
||||
public void setBirthWeight(Long birthWeight) {
|
||||
this.birthWeight = birthWeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Long getWeaningWeight() {
|
||||
return weaningWeight;
|
||||
}
|
||||
|
||||
public void setWeaningWeight(Long weaningWeight) {
|
||||
this.weaningWeight = weaningWeight;
|
||||
}
|
||||
|
||||
public Long getCurrentWeight() {
|
||||
return currentWeight;
|
||||
}
|
||||
|
||||
public void setCurrentWeight(Long currentWeight) {
|
||||
this.currentWeight = currentWeight;
|
||||
}
|
||||
|
||||
public String getBreed() {
|
||||
return breed;
|
||||
}
|
||||
|
||||
public void setBreed(String breed) {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
public String getFatherManageTags() {
|
||||
return fatherManageTags;
|
||||
}
|
||||
|
||||
public void setFatherManageTags(String fatherManageTags) {
|
||||
this.fatherManageTags = fatherManageTags;
|
||||
}
|
||||
|
||||
public String getMotherManageTags() {
|
||||
return motherManageTags;
|
||||
}
|
||||
|
||||
public void setMotherManageTags(String motherManageTags) {
|
||||
this.motherManageTags = motherManageTags;
|
||||
}
|
||||
}
|
||||
@ -31,4 +31,13 @@ public class BasSheepGroupMapping extends BaseEntity
|
||||
@Excel(name = "分组ID")
|
||||
private Long groupId;
|
||||
|
||||
@Excel(name = "耳号")
|
||||
private String bsManageTags; // 或者 List<String>、其他类型
|
||||
public String getBsManageTags() {
|
||||
return bsManageTags;
|
||||
}
|
||||
public void setBsManageTags(String bsManageTags) {
|
||||
this.bsManageTags = bsManageTags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,70 @@ public class DaSheepfold extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getRanchId() {
|
||||
return ranchId;
|
||||
}
|
||||
|
||||
public void setRanchId(Long ranchId) {
|
||||
this.ranchId = ranchId;
|
||||
}
|
||||
|
||||
public String getSheepfoldName() {
|
||||
return sheepfoldName;
|
||||
}
|
||||
|
||||
public void setSheepfoldName(String sheepfoldName) {
|
||||
this.sheepfoldName = sheepfoldName;
|
||||
}
|
||||
|
||||
public Long getSheepfoldTypeId() {
|
||||
return sheepfoldTypeId;
|
||||
}
|
||||
|
||||
public void setSheepfoldTypeId(Long sheepfoldTypeId) {
|
||||
this.sheepfoldTypeId = sheepfoldTypeId;
|
||||
}
|
||||
|
||||
public String getSheepfoldNo() {
|
||||
return sheepfoldNo;
|
||||
}
|
||||
|
||||
public void setSheepfoldNo(String sheepfoldNo) {
|
||||
this.sheepfoldNo = sheepfoldNo;
|
||||
}
|
||||
|
||||
public String getRowNo() {
|
||||
return rowNo;
|
||||
}
|
||||
|
||||
public void setRowNo(String rowNo) {
|
||||
this.rowNo = rowNo;
|
||||
}
|
||||
|
||||
public String getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(String columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
/** 羊舍id */
|
||||
@Excel(name = "羊舍id")
|
||||
private Long id;
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.module.base.domain.BasSheepGroupMapping;
|
||||
import com.zhyc.module.base.domain.BasGroupTreeVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
/**
|
||||
@ -85,4 +86,6 @@ public interface BasSheepGroupMappingMapper
|
||||
|
||||
List<BasSheepGroupMapping> selectListByGroupId(@Param("groupId") Long groupId);
|
||||
|
||||
List<BasGroupTreeVo> selectGroupTree();
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.module.base.domain.BasGroupTreeVo;
|
||||
import com.zhyc.module.base.domain.BasSheepGroupMapping;
|
||||
|
||||
/**
|
||||
@ -70,4 +71,9 @@ public interface IBasSheepGroupMappingService
|
||||
public int deleteBasSheepGroupMappingById(Long id);
|
||||
|
||||
public AjaxResult addByEarTags(List<String> earTags, Long groupId);
|
||||
|
||||
/**
|
||||
* 树形分组下拉框
|
||||
*/
|
||||
List<BasGroupTreeVo> selectGroupTree();
|
||||
}
|
||||
|
||||
@ -4,12 +4,14 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.module.base.domain.BasGroupTreeVo;
|
||||
import com.zhyc.module.base.domain.BasSheepGroupMapping;
|
||||
import com.zhyc.module.base.mapper.BasSheepGroupMappingMapper;
|
||||
import com.zhyc.module.base.service.IBasSheepGroupMappingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* 羊只分组关联Service业务层处理
|
||||
*
|
||||
@ -185,5 +187,29 @@ public class BasSheepGroupMappingServiceImpl implements IBasSheepGroupMappingSer
|
||||
}
|
||||
|
||||
|
||||
private List<BasGroupTreeVo> buildTree(List<BasGroupTreeVo> all) {
|
||||
Map<Long, BasGroupTreeVo> map = all.stream()
|
||||
.collect(Collectors.toMap(BasGroupTreeVo::getGroupId, v -> v));
|
||||
List<BasGroupTreeVo> tree = new ArrayList<>();
|
||||
for (BasGroupTreeVo n : all) {
|
||||
if (n.getParentId() == null || n.getParentId() == 0L) {
|
||||
tree.add(n);
|
||||
} else {
|
||||
BasGroupTreeVo parent = map.get(n.getParentId());
|
||||
if (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
@Override
|
||||
public List<BasGroupTreeVo> selectGroupTree() {
|
||||
List<BasGroupTreeVo> list = basSheepGroupMappingMapper.selectGroupTree();
|
||||
return buildTree(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -80,6 +80,18 @@ public class DiagnosisController extends BaseController
|
||||
return toAjax(diagnosisService.insertDiagnosis(diagnosis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增批量诊疗结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('diagnosis:diagnosis:add')")
|
||||
@Log(title = "诊疗结果", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/adds")
|
||||
public AjaxResult adds(@RequestBody Diagnosis diagnosis)
|
||||
{
|
||||
System.out.println(diagnosis);
|
||||
return toAjax(diagnosisService.insertDiagnosisList(diagnosis));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改诊疗结果
|
||||
*/
|
||||
|
||||
@ -11,7 +11,7 @@ import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 驱虫对象 sw_deworm
|
||||
* 驱虫对象 sw_dih
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-15
|
||||
|
||||
@ -27,6 +27,7 @@ public class Diagnosis extends BaseEntity
|
||||
/** 治疗记录id */
|
||||
@Excel(name = "治疗记录")
|
||||
private Long treatId;
|
||||
private Integer[] treatIds;
|
||||
|
||||
/** 羊只id */
|
||||
@Excel(name = "羊只耳号")
|
||||
|
||||
@ -58,6 +58,8 @@ public class Disinfect extends BaseEntity
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
/** 药品名称用于查询*/
|
||||
private String mediName;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.zhyc.module.biosafety.domain;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -28,6 +30,18 @@ public class SwMedicineUsage extends BaseEntity
|
||||
@Excel(name = "使用名称")
|
||||
private String name;
|
||||
|
||||
/** 羊舍名称 */
|
||||
@Excel(name = "使用名称")
|
||||
private String sheepfoldName;
|
||||
private Integer sheepfoldId;
|
||||
/** 耳号 */
|
||||
@Excel(name = "耳号")
|
||||
private String sheepNo;
|
||||
private Integer sheepId;
|
||||
/** 使用时间 */
|
||||
@Excel(name = "使用时间")
|
||||
private Date datetime;
|
||||
|
||||
/** 使用类型 */
|
||||
@Excel(name = "使用类型")
|
||||
private String useType;
|
||||
|
||||
@ -49,90 +49,4 @@ public class SwPrescription extends BaseEntity
|
||||
/** 处方详情信息 */
|
||||
private List<SwPresDetail> swPresDetailList;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setNo(String no)
|
||||
{
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
public String getNo()
|
||||
{
|
||||
return no;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPersType(Integer persType)
|
||||
{
|
||||
this.persType = persType;
|
||||
}
|
||||
|
||||
public Integer getPersType()
|
||||
{
|
||||
return persType;
|
||||
}
|
||||
|
||||
public void setComment(String comment)
|
||||
{
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getComment()
|
||||
{
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<SwPresDetail> getSwPresDetailList()
|
||||
{
|
||||
return swPresDetailList;
|
||||
}
|
||||
|
||||
public void setSwPresDetailList(List<SwPresDetail> swPresDetailList)
|
||||
{
|
||||
this.swPresDetailList = swPresDetailList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("no", getNo())
|
||||
.append("name", getName())
|
||||
.append("persType", getPersType())
|
||||
.append("comment", getComment())
|
||||
.append("status", getStatus())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("swPresDetailList", getSwPresDetailList())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,4 +59,6 @@ public interface IDiagnosisService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDiagnosisById(Long id);
|
||||
|
||||
int insertDiagnosisList(Diagnosis diagnosis);
|
||||
}
|
||||
|
||||
@ -72,12 +72,13 @@ public class DewormServiceImpl implements IDewormService
|
||||
@Transactional
|
||||
public int insertDeworm(Deworm deworm)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(deworm.getUsageDetails());
|
||||
medicineUsage.setName("羊只驱虫");
|
||||
medicineUsage.setUseType("1");
|
||||
medicineUsage.setDatetime(deworm.getDatetime());
|
||||
|
||||
List<Deworm> deworms = new ArrayList<>();
|
||||
|
||||
@ -95,6 +96,8 @@ public class DewormServiceImpl implements IDewormService
|
||||
dew.setGender(String.valueOf(sheepFile.getGender()));
|
||||
dew.setBreed(sheepFile.getBreed());
|
||||
dew.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
dew.setUsageId(usageId);
|
||||
@ -115,7 +118,7 @@ public class DewormServiceImpl implements IDewormService
|
||||
@Transactional
|
||||
public int updateDeworm(Deworm deworm)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
for (SwMedicineUsageDetails usageDetail : deworm.getUsageDetails()) {
|
||||
usageDetail.setMediUsage(deworm.getUsageId());
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
diagnosis.setGender(String.valueOf(sheepFile.getGender()));
|
||||
diagnosis.setMonthAge(sheepFile.getMonthAge());
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
diagnosis.setCreateBy(username);
|
||||
diagnosis.setCreateTime(DateUtils.getNowDate());
|
||||
if (!Objects.equals(sheepFile.getSheepfoldId(), diagnosis.getSheepfoldId())){
|
||||
@ -85,6 +85,13 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
return diagnosisMapper.insertDiagnosis(diagnosis);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertDiagnosisList(Diagnosis diagnosis) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改诊疗结果
|
||||
*
|
||||
@ -98,7 +105,7 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
BasSheep basSheep = new BasSheep();
|
||||
basSheep.setId(diagnosis.getSheepId());
|
||||
basSheep.setSheepfoldId(diagnosis.getSheepfoldId());
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
basSheep.setUpdateBy(username);
|
||||
basSheep.setUpdateTime(DateUtils.getNowDate());
|
||||
diagnosis.setUpdateBy(username);
|
||||
@ -130,4 +137,5 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
{
|
||||
return diagnosisMapper.deleteDiagnosisById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -73,12 +73,13 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
@Override
|
||||
public int insertDisinfect(Disinfect disinfect)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(disinfect.getUsageDetails());
|
||||
medicineUsage.setName("羊舍消毒");
|
||||
medicineUsage.setUseType("3");
|
||||
medicineUsage.setDatetime(disinfect.getDatetime());
|
||||
|
||||
|
||||
List<Disinfect> disinfects = new ArrayList<>();
|
||||
@ -90,6 +91,8 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
Disinfect dis = new Disinfect();
|
||||
BeanUtils.copyProperties(disinfect,dis);
|
||||
dis.setSheepfoldId(sheepfold);
|
||||
|
||||
medicineUsage.setSheepfoldId(sheepfold);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
dis.setUsageId(usageId);
|
||||
@ -114,7 +117,7 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
}
|
||||
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(disinfect.getUsageId());
|
||||
medicineUsageMapper.batchSwMedicineUsageDetails(disinfect.getUsageDetails());
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
disinfect.setUpdateBy(username);
|
||||
disinfect.setUpdateTime(DateUtils.getNowDate());
|
||||
return disinfectMapper.updateDisinfect(disinfect);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
@ -70,16 +71,18 @@ public class HealthServiceImpl implements IHealthService
|
||||
* @param health 保健
|
||||
* @return 结果
|
||||
*/
|
||||
@Transient
|
||||
@Override
|
||||
public int insertHealth(Health health)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(health.getUsageDetails());
|
||||
medicineUsage.setName("羊只保健");
|
||||
medicineUsage.setUseType("2");
|
||||
medicineUsage.setDatetime(health.getDatetime());
|
||||
|
||||
List<Health> healths = new ArrayList<>();
|
||||
health.setCreateBy(username);
|
||||
@ -96,6 +99,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
heal.setBreed(sheepFile.getBreed());
|
||||
heal.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
|
||||
@ -119,7 +123,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
}
|
||||
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(health.getUsageId());
|
||||
medicineUsageMapper.batchSwMedicineUsageDetails(health.getUsageDetails());
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
health.setUpdateBy(username);
|
||||
health.setUpdateTime(DateUtils.getNowDate());
|
||||
return healthMapper.updateHealth(health);
|
||||
|
||||
@ -75,15 +75,17 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
@Override
|
||||
public int insertImmunity(Immunity immunity)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(immunity.getUsageDetails());
|
||||
medicineUsage.setName("羊只免疫");
|
||||
medicineUsage.setUseType("0");
|
||||
medicineUsage.setDatetime(immunity.getDatetime());
|
||||
medicineUsage.setCreateBy(username);
|
||||
|
||||
|
||||
List<Immunity> immunities = new ArrayList<>();
|
||||
|
||||
immunity.setUpdateBy(username);
|
||||
@ -101,6 +103,8 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
imm.setGender(String.valueOf(sheepFile.getGender()));
|
||||
imm.setBreed(sheepFile.getBreed());
|
||||
imm.setParity(sheepFile.getParity());
|
||||
|
||||
medicineUsage.setSheepId(sheepId);
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
|
||||
@ -128,6 +132,8 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
}
|
||||
medicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(immunity.getUsageId());
|
||||
medicineUsageMapper.batchSwMedicineUsageDetails(immunity.getUsageDetails());
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
immunity.setUpdateBy(username);
|
||||
immunity.setUpdateTime(DateUtils.getNowDate());
|
||||
return immunityMapper.updateImmunity(immunity);
|
||||
}
|
||||
|
||||
@ -60,10 +60,10 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
|
||||
@Override
|
||||
public int insertQuarantineReport(QuarantineReport quarantineReport)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
quarantineReport.setCreateBy(username);
|
||||
quarantineReport.setCreateTime(DateUtils.getNowDate());
|
||||
if (quarantineReport.getResult()==null){
|
||||
if (quarantineReport.getResult()==null || quarantineReport.getResult().length()==0){
|
||||
quarantineReport.setStatus(0);
|
||||
}else {
|
||||
quarantineReport.setStatus(1);
|
||||
@ -96,7 +96,7 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
|
||||
@Override
|
||||
public int updateQuarantineReport(QuarantineReport quarantineReport)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
quarantineReport.setUpdateBy(username);
|
||||
quarantineReport.setUpdateTime(DateUtils.getNowDate());
|
||||
return quarantineReportMapper.updateQuarantineReport(quarantineReport);
|
||||
|
||||
@ -59,7 +59,7 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
|
||||
@Override
|
||||
public int insertSwMedicineUsage(SwMedicineUsage swMedicineUsage)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
swMedicineUsage.setCreateBy(username);
|
||||
swMedicineUsage.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = swMedicineUsageMapper.insertSwMedicineUsage(swMedicineUsage);
|
||||
@ -77,7 +77,7 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
|
||||
@Override
|
||||
public int updateSwMedicineUsage(SwMedicineUsage swMedicineUsage)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
swMedicineUsage.setUpdateBy(username);
|
||||
swMedicineUsage.setUpdateTime(DateUtils.getNowDate());
|
||||
swMedicineUsageMapper.deleteSwMedicineUsageDetailsByMediUsage(swMedicineUsage.getId());
|
||||
|
||||
@ -59,7 +59,8 @@ public class SwPrescriptionServiceImpl implements ISwPrescriptionService
|
||||
@Override
|
||||
public int insertSwPrescription(SwPrescription swPrescription)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
// 获取创建人的用户名称
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
swPrescription.setCreateBy(username);
|
||||
swPrescription.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = swPrescriptionMapper.insertSwPrescription(swPrescription);
|
||||
@ -77,7 +78,7 @@ public class SwPrescriptionServiceImpl implements ISwPrescriptionService
|
||||
@Override
|
||||
public int updateSwPrescription(SwPrescription swPrescription)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
swPrescription.setUpdateBy(username);
|
||||
swPrescription.setUpdateTime(DateUtils.getNowDate());
|
||||
swPrescriptionMapper.deleteSwPresDetailByPersId(swPrescription.getId());
|
||||
|
||||
@ -73,16 +73,18 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
@Transactional
|
||||
public int insertTreatment(Treatment treatment)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
// 使用记录的文件
|
||||
SwMedicineUsage medicineUsage = new SwMedicineUsage();
|
||||
medicineUsage.setSwMedicineUsageDetailsList(treatment.getUsageDetails());
|
||||
medicineUsage.setName("羊只治疗");
|
||||
medicineUsage.setUseType("4");
|
||||
medicineUsage.setDatetime(treatment.getDatetime());
|
||||
medicineUsage.setCreateBy(username);
|
||||
medicineUsage.setCreateTime(DateUtils.getNowDate());
|
||||
// 新增单挑数据
|
||||
if (treatment.getSheepId()!=null){
|
||||
medicineUsage.setSheepId(Math.toIntExact(treatment.getSheepId()));
|
||||
// 药品使用记录
|
||||
Integer id=medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
// 药品使用记录id
|
||||
@ -108,6 +110,8 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
treat.setParity(sheepFile.getParity());
|
||||
treat.setLactDay(sheepFile.getLactationDay());
|
||||
treat.setGestDay(sheepFile.getGestationDay());
|
||||
|
||||
medicineUsage.setSheepId(Integer.valueOf(sheepId));
|
||||
// 获取药品使用记录的id
|
||||
Integer usageId = medicineUsageService.insertSwMedicineUsage(medicineUsage);
|
||||
System.out.println(medicineUsage);
|
||||
@ -134,7 +138,7 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
@Transactional
|
||||
public int updateTreatment(Treatment treatment)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
String username = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
for (SwMedicineUsageDetails usageDetail : treatment.getUsageDetails()) {
|
||||
usageDetail.setMediUsage(treatment.getUsageId());
|
||||
}
|
||||
|
||||
@ -0,0 +1,236 @@
|
||||
package com.zhyc.module.feed.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhyc.module.feed.domain.SgFeedPlan;
|
||||
import com.zhyc.module.feed.domain.SgFormulaManagement;
|
||||
import com.zhyc.module.feed.service.ISgFeedPlanService;
|
||||
import com.zhyc.module.feed.service.ISgFormulaManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.zhyc.common.annotation.Log;
|
||||
import com.zhyc.common.core.controller.BaseController;
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import com.zhyc.common.enums.BusinessType;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
import com.zhyc.common.utils.poi.ExcelUtil;
|
||||
import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 配料清单Controller
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feed/FeedList")
|
||||
public class SgFeedListController extends BaseController {
|
||||
private final ISgFeedListService sgFeedListService;
|
||||
|
||||
private final ISgFormulaManagementService sgFormulaManagementService;
|
||||
|
||||
private final ISgFeedPlanService sgFeedPlanService;
|
||||
|
||||
private final Map<String, SgFeedList> sgFeedListMap = new HashMap<>();
|
||||
|
||||
public static boolean refresh = true;
|
||||
|
||||
@Autowired
|
||||
public SgFeedListController(ISgFeedListService sgFeedListService, ISgFormulaManagementService sgFormulaManagementService, ISgFeedPlanService sgFeedPlanService) {
|
||||
this.sgFeedListService = sgFeedListService;
|
||||
this.sgFormulaManagementService = sgFormulaManagementService;
|
||||
this.sgFeedPlanService = sgFeedPlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:list')")
|
||||
@GetMapping("/list")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TableDataInfo list(SgFeedList sgFeedList) {
|
||||
/*
|
||||
刷新缓存
|
||||
当配方管理表出现更新 或 饲喂计划表出现增删改时会将refresh置为true 通知此处进行刷新
|
||||
*/
|
||||
if (refresh) {
|
||||
SyncFeedList();
|
||||
refresh = false;
|
||||
}
|
||||
startPage();
|
||||
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
|
||||
// 用 map 中已有的数据替换 list 中的元素
|
||||
List<SgFeedList> replacedList = new ArrayList<>();
|
||||
for (SgFeedList item : list) {
|
||||
String key = item.getFormulaId() + "_" + item.getFormulaBatchId();
|
||||
// 从缓存中取出完整对象
|
||||
SgFeedList itemInCache = sgFeedListMap.getOrDefault(key, item);
|
||||
// 将数据库查询的基本信息替换掉缓存中去除的内容 - 前端展示与修改需要
|
||||
itemInCache.setId(item.getId());
|
||||
itemInCache.setFormulaBatchId(item.getFormulaBatchId());
|
||||
itemInCache.setFormulaId(item.getFormulaId());
|
||||
itemInCache.setZookeeper(item.getZookeeper());
|
||||
itemInCache.setDeployDate(item.getDeployDate());
|
||||
// 替换为 map 中的对象
|
||||
replacedList.add(itemInCache);
|
||||
}
|
||||
return getDataTable(replacedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配料清单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:export')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SgFeedList sgFeedList) {
|
||||
List<SgFeedList> list = sgFeedListService.selectSgFeedListList(sgFeedList);
|
||||
ExcelUtil<SgFeedList> util = new ExcelUtil<>(SgFeedList.class);
|
||||
util.exportExcel(response, list, "配料清单数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配料清单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(sgFeedListService.selectSgFeedListById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:add')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SgFeedList sgFeedList) {
|
||||
return toAjax(sgFeedListService.insertSgFeedList(sgFeedList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:edit')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SgFeedList sgFeedList) {
|
||||
return toAjax(sgFeedListService.updateSgFeedList(sgFeedList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配料清单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:FeedList:remove')")
|
||||
@Log(title = "配料清单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(sgFeedListService.deleteSgFeedListByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
public void SyncFeedList() {
|
||||
// 清空旧缓存
|
||||
sgFeedListMap.clear();
|
||||
// 获取配方管理和现有配料清单内容
|
||||
List<SgFormulaManagement> formulaManagementList = sgFormulaManagementService.selectSgFormulaManagementList(new SgFormulaManagement());
|
||||
List<SgFeedList> feedLists = sgFeedListService.selectSgFeedListList(new SgFeedList());
|
||||
// 将最新查询的配料清单加入缓存
|
||||
for (SgFeedList sgFeedList : feedLists) {
|
||||
sgFeedListMap.put(sgFeedList.getFormulaId() + "_" + sgFeedList.getFormulaBatchId(), sgFeedList);
|
||||
}
|
||||
// 与新的配方管理列表同步 - 如果配料清单没有对应数据则加入
|
||||
for (SgFormulaManagement sgFormulaManagement : formulaManagementList) {
|
||||
// 匹配 但忽略模板配方
|
||||
if (sgFormulaManagement.getFormulaId() != null && sgFormulaManagement.getBatchId() != null && !sgFormulaManagement.getBatchId().equals("0")) {
|
||||
// 查询当前配方管理项是否存在现有配料计划中 (不论是否存在都要设置,因为缓存被清空,存在则更新,不存在则插入)
|
||||
boolean isExist = sgFeedListMap.containsKey(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId());
|
||||
// 标志位 : 如果当前配方不在饲喂计划中则不生成配量清单
|
||||
boolean isPlan = true;
|
||||
// 设置缓存对象具体值
|
||||
SgFeedList sgFeedList = new SgFeedList();
|
||||
sgFeedList.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFeedList.setFormulaBatchId(sgFormulaManagement.getBatchId());
|
||||
sgFeedList.setFormulaList(sgFormulaManagement.getSgFormulaList());
|
||||
sgFeedList.setRootFormula(sgFormulaManagement);
|
||||
|
||||
|
||||
// 从饲喂计划列表中查出对应值(饲喂量需要计划中的比例计算)
|
||||
SgFeedPlan rootPlanQuery = new SgFeedPlan();
|
||||
rootPlanQuery.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
rootPlanQuery.setBatchId(sgFormulaManagement.getBatchId());
|
||||
List<SgFeedPlan> sgFeedPlans = sgFeedPlanService.selectSgFeedPlanList(rootPlanQuery);
|
||||
// 为空则标识当前配方不在饲喂计划中 && 不在缓存中设置
|
||||
if (sgFeedPlans.isEmpty()) {
|
||||
isPlan = false;
|
||||
} else {
|
||||
// rootPlan中存储的是该配方批号的总量
|
||||
SgFeedPlan rootPlan = computePlanTotal(sgFeedPlans);
|
||||
|
||||
// 将计划实体对象设置到配料清单中
|
||||
sgFeedList.setRootPlan(rootPlan);
|
||||
|
||||
// 完整的配料清单对象加入缓存
|
||||
sgFeedListMap.put(sgFormulaManagement.getFormulaId() + "_" + sgFormulaManagement.getBatchId(), sgFeedList);
|
||||
}
|
||||
|
||||
// 不存在则插入
|
||||
if (!isExist && isPlan) {
|
||||
sgFeedListService.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算某个配方某个批次的总和值
|
||||
*
|
||||
* @param sgFeedPlans 配方计划列表
|
||||
* @return 各个值总和
|
||||
*/
|
||||
private static SgFeedPlan computePlanTotal(List<SgFeedPlan> sgFeedPlans) {
|
||||
SgFeedPlan rootPlan = new SgFeedPlan();
|
||||
if (!sgFeedPlans.isEmpty()) {
|
||||
int sheepCountTotal = 0;
|
||||
double sheepDailySize = 0.0;
|
||||
double planFeedMorningSize = 0.0;
|
||||
double planFeedNoonSize = 0.0;
|
||||
double planFeedAfternoonSize = 0.0;
|
||||
double planFeedTotalSize = 0.0;
|
||||
for (SgFeedPlan sgFeedPlan : sgFeedPlans) {
|
||||
sheepCountTotal += sgFeedPlan.getSheepCount();
|
||||
sheepDailySize += sgFeedPlan.getPlanDailySize();
|
||||
planFeedMorningSize += sgFeedPlan.getPlanMorningSize();
|
||||
planFeedNoonSize += sgFeedPlan.getPlanNoonSize();
|
||||
planFeedAfternoonSize += sgFeedPlan.getPlanAfternoonSize();
|
||||
planFeedTotalSize += sgFeedPlan.getPlanFeedTotal();
|
||||
}
|
||||
|
||||
rootPlan.setSheepCount(sheepCountTotal);
|
||||
rootPlan.setPlanDailySize(sheepDailySize);
|
||||
rootPlan.setPlanMorningSize(planFeedMorningSize);
|
||||
rootPlan.setPlanNoonSize(planFeedNoonSize);
|
||||
rootPlan.setPlanAfternoonSize(planFeedAfternoonSize);
|
||||
rootPlan.setPlanFeedTotal(planFeedTotalSize);
|
||||
|
||||
// 设置计划日期
|
||||
rootPlan.setPlanDate(sgFeedPlans.get(0).getPlanDate());
|
||||
}
|
||||
return rootPlan;
|
||||
}
|
||||
}
|
||||
@ -82,6 +82,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
sgFeedPlan.setCreateDate(new Date());
|
||||
// 计算其他字段值
|
||||
setPlan(sgFeedPlan);
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.insertSgFeedPlan(sgFeedPlan));
|
||||
}
|
||||
|
||||
@ -94,6 +96,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
public AjaxResult edit(@RequestBody SgFeedPlan sgFeedPlan) {
|
||||
// 根据修改后的值重新计算
|
||||
setPlan(sgFeedPlan);
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.updateSgFeedPlan(sgFeedPlan));
|
||||
}
|
||||
|
||||
@ -104,6 +108,8 @@ public class SgFeedPlanController extends BaseController {
|
||||
@Log(title = "饲喂计划", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{createDates}")
|
||||
public AjaxResult remove(@PathVariable Date[] createDates) {
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFeedPlanService.deleteSgFeedPlanByCreateDates(createDates));
|
||||
}
|
||||
|
||||
@ -111,7 +117,7 @@ public class SgFeedPlanController extends BaseController {
|
||||
* 设定计划值
|
||||
* 用于添加和修改
|
||||
*/
|
||||
private SgFeedPlan setPlan(SgFeedPlan sgFeedPlan) {
|
||||
private void setPlan(SgFeedPlan sgFeedPlan) {
|
||||
// 根据羊舍ID获取羊只数量
|
||||
int countByFoldId = sgFeedPlanService.getSheepCountByFoldId(sgFeedPlan.getSheepHouseId());
|
||||
sgFeedPlan.setSheepCount(countByFoldId);
|
||||
@ -121,6 +127,5 @@ public class SgFeedPlanController extends BaseController {
|
||||
sgFeedPlan.setPlanMorningSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioMorning() / 100));
|
||||
sgFeedPlan.setPlanNoonSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioNoon() / 100));
|
||||
sgFeedPlan.setPlanAfternoonSize(sgFeedPlan.getPlanFeedTotal() * (sgFeedPlan.getRatioAfternoon() / 100));
|
||||
return sgFeedPlan;
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,6 +143,9 @@ public class SgFormulaManagementController extends BaseController {
|
||||
sgFormulaListItem.setFormulaId(sgFormulaManagement.getFormulaId());
|
||||
sgFormulaListService.insertSgFormulaList(sgFormulaListItem);
|
||||
}
|
||||
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFormulaManagementService.updateSgFormulaManagement(sgFormulaManagement));
|
||||
}
|
||||
|
||||
@ -167,6 +170,9 @@ public class SgFormulaManagementController extends BaseController {
|
||||
}
|
||||
// 前置检查完毕 执行删除
|
||||
sgFormulaManagement.setBatchId(batchId);
|
||||
|
||||
// 通知配料清单刷新数据
|
||||
SgFeedListController.refresh = true;
|
||||
return toAjax(sgFormulaManagementService.deleteSgFormulaManagement(sgFormulaManagement));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.zhyc.module.feed.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 配料清单对象 sg_feed_list
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class SgFeedList extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 序号 */
|
||||
private Long id;
|
||||
|
||||
/** 配方编号 */
|
||||
@Excel(name = "配方编号")
|
||||
private String formulaId;
|
||||
|
||||
/** 配方批号 */
|
||||
@Excel(name = "配方批号")
|
||||
private String formulaBatchId;
|
||||
|
||||
/** 饲草班人员 */
|
||||
@Excel(name = "饲草班人员")
|
||||
private String zookeeper;
|
||||
|
||||
/** 配料日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "配料日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date deployDate;
|
||||
|
||||
private SgFormulaManagement rootFormula;
|
||||
|
||||
private SgFeedPlan rootPlan;
|
||||
|
||||
private Double morningTotal;
|
||||
private Double noonTotal;
|
||||
private Double afternoonTotal;
|
||||
|
||||
private List<SgFormulaList> formulaList;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("formulaId", getFormulaId())
|
||||
.append("formulaBatchId", getFormulaBatchId())
|
||||
.append("zookeeper", getZookeeper())
|
||||
.append("deployDate", getDeployDate())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.zhyc.module.feed.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 配料清单Mapper接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Mapper
|
||||
public interface SgFeedListMapper
|
||||
{
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
SgFeedList selectSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单集合
|
||||
*/
|
||||
List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 删除配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListByIds(Long[] ids);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.zhyc.module.feed.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
|
||||
/**
|
||||
* 配料清单Service接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface ISgFeedListService
|
||||
{
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
SgFeedList selectSgFeedListById(Long id);
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单集合
|
||||
*/
|
||||
List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgFeedList(SgFeedList sgFeedList);
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的配料清单主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除配料清单信息
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgFeedListById(Long id);
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package com.zhyc.module.feed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.feed.mapper.SgFeedListMapper;
|
||||
import com.zhyc.module.feed.domain.SgFeedList;
|
||||
import com.zhyc.module.feed.service.ISgFeedListService;
|
||||
|
||||
/**
|
||||
* 配料清单Service业务层处理
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SgFeedListServiceImpl implements ISgFeedListService
|
||||
{
|
||||
private final SgFeedListMapper sgFeedListMapper;
|
||||
|
||||
public SgFeedListServiceImpl(SgFeedListMapper sgFeedListMapper) {
|
||||
this.sgFeedListMapper = sgFeedListMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public SgFeedList selectSgFeedListById(Long id)
|
||||
{
|
||||
return sgFeedListMapper.selectSgFeedListById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料清单列表
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 配料清单
|
||||
*/
|
||||
@Override
|
||||
public List<SgFeedList> selectSgFeedListList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.selectSgFeedListList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.insertSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配料清单
|
||||
*
|
||||
* @param sgFeedList 配料清单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSgFeedList(SgFeedList sgFeedList)
|
||||
{
|
||||
return sgFeedListMapper.updateSgFeedList(sgFeedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除配料清单
|
||||
*
|
||||
* @param ids 需要删除的配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListByIds(Long[] ids)
|
||||
{
|
||||
return sgFeedListMapper.deleteSgFeedListByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配料清单信息
|
||||
*
|
||||
* @param id 配料清单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgFeedListById(Long id)
|
||||
{
|
||||
return sgFeedListMapper.deleteSgFeedListById(id);
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,10 @@
|
||||
package com.zhyc.module.produce.breed.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.zhyc.module.produce.breed.mapper.ScSheepDeathMapper;
|
||||
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
|
||||
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
|
||||
@ -36,7 +33,19 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
// 查询时也需要填充显示字段
|
||||
if (scSheepDeath != null && scSheepDeath.getManageTags() != null) {
|
||||
fillSheepDisplayInfo(scSheepDeath);
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setVariety(sheepInfo.get("variety") != null ? sheepInfo.get("variety").toString() : null);
|
||||
scSheepDeath.setSheepType(sheepInfo.get("sheepType") != null ? sheepInfo.get("sheepType").toString() : null);
|
||||
scSheepDeath.setGender(sheepInfo.get("gender") != null ? Integer.valueOf(sheepInfo.get("gender").toString()) : null);
|
||||
scSheepDeath.setDayAge(sheepInfo.get("dayAge") != null ? Long.valueOf(sheepInfo.get("dayAge").toString()) : null);
|
||||
scSheepDeath.setParity(sheepInfo.get("parity") != null ? Integer.valueOf(sheepInfo.get("parity").toString()) : null);
|
||||
scSheepDeath.setSheepfoldName(sheepInfo.get("sheepfoldName") != null ? sheepInfo.get("sheepfoldName").toString() : null);
|
||||
scSheepDeath.setBreedStatus(sheepInfo.get("breedStatus") != null ? sheepInfo.get("breedStatus").toString() : null);
|
||||
scSheepDeath.setPostLambingDay(sheepInfo.get("postLambingDay") != null ? Integer.valueOf(sheepInfo.get("postLambingDay").toString()) : null);
|
||||
scSheepDeath.setLactationDay(sheepInfo.get("lactationDay") != null ? Integer.valueOf(sheepInfo.get("lactationDay").toString()) : null);
|
||||
scSheepDeath.setGestationDay(sheepInfo.get("gestationDay") != null ? Integer.valueOf(sheepInfo.get("gestationDay").toString()) : null);
|
||||
}
|
||||
}
|
||||
return scSheepDeath;
|
||||
}
|
||||
@ -54,33 +63,24 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
// 为列表中的每条记录填充显示字段
|
||||
for (ScSheepDeath death : list) {
|
||||
if (death.getManageTags() != null) {
|
||||
fillSheepDisplayInfo(death);
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(death.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
death.setVariety(sheepInfo.get("variety") != null ? sheepInfo.get("variety").toString() : null);
|
||||
death.setSheepType(sheepInfo.get("sheepType") != null ? sheepInfo.get("sheepType").toString() : null);
|
||||
death.setGender(sheepInfo.get("gender") != null ? Integer.valueOf(sheepInfo.get("gender").toString()) : null);
|
||||
death.setDayAge(sheepInfo.get("dayAge") != null ? Long.valueOf(sheepInfo.get("dayAge").toString()) : null);
|
||||
death.setParity(sheepInfo.get("parity") != null ? Integer.valueOf(sheepInfo.get("parity").toString()) : null);
|
||||
death.setSheepfoldName(sheepInfo.get("sheepfoldName") != null ? sheepInfo.get("sheepfoldName").toString() : null);
|
||||
death.setBreedStatus(sheepInfo.get("breedStatus") != null ? sheepInfo.get("breedStatus").toString() : null);
|
||||
death.setPostLambingDay(sheepInfo.get("postLambingDay") != null ? Integer.valueOf(sheepInfo.get("postLambingDay").toString()) : null);
|
||||
death.setLactationDay(sheepInfo.get("lactationDay") != null ? Integer.valueOf(sheepInfo.get("lactationDay").toString()) : null);
|
||||
death.setGestationDay(sheepInfo.get("gestationDay") != null ? Integer.valueOf(sheepInfo.get("gestationDay").toString()) : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充羊只显示信息(提取公共方法避免重复代码)
|
||||
*
|
||||
* @param scSheepDeath 死淘记录对象
|
||||
*/
|
||||
private void fillSheepDisplayInfo(ScSheepDeath scSheepDeath) {
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
|
||||
if (sheepInfo != null) {
|
||||
scSheepDeath.setVariety(sheepInfo.get("variety") != null ? sheepInfo.get("variety").toString() : null);
|
||||
scSheepDeath.setSheepType(sheepInfo.get("sheepType") != null ? sheepInfo.get("sheepType").toString() : null);
|
||||
scSheepDeath.setGender(sheepInfo.get("gender") != null ? Integer.valueOf(sheepInfo.get("gender").toString()) : null);
|
||||
scSheepDeath.setDayAge(sheepInfo.get("dayAge") != null ? Long.valueOf(sheepInfo.get("dayAge").toString()) : null);
|
||||
scSheepDeath.setParity(sheepInfo.get("parity") != null ? Integer.valueOf(sheepInfo.get("parity").toString()) : null);
|
||||
scSheepDeath.setSheepfoldName(sheepInfo.get("sheepfoldName") != null ? sheepInfo.get("sheepfoldName").toString() : null);
|
||||
scSheepDeath.setBreedStatus(sheepInfo.get("breedStatus") != null ? sheepInfo.get("breedStatus").toString() : null);
|
||||
scSheepDeath.setPostLambingDay(sheepInfo.get("postLambingDay") != null ? Integer.valueOf(sheepInfo.get("postLambingDay").toString()) : null);
|
||||
scSheepDeath.setLactationDay(sheepInfo.get("lactationDay") != null ? Integer.valueOf(sheepInfo.get("lactationDay").toString()) : null);
|
||||
scSheepDeath.setGestationDay(sheepInfo.get("gestationDay") != null ? Integer.valueOf(sheepInfo.get("gestationDay").toString()) : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据管理耳号查询sheep_file视图信息
|
||||
*
|
||||
@ -100,55 +100,23 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScSheepDeath(ScSheepDeath scSheepDeath)
|
||||
{
|
||||
// 参数校验
|
||||
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
|
||||
// 设置事件类型默认为"死亡"
|
||||
if (scSheepDeath.getEventType() == null || scSheepDeath.getEventType().isEmpty()) {
|
||||
scSheepDeath.setEventType("死亡");
|
||||
}
|
||||
|
||||
// 查询羊只信息并验证是否存在
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags().trim());
|
||||
if (sheepInfo == null) {
|
||||
throw new ServiceException("管理耳号[" + scSheepDeath.getManageTags() + "]对应的羊只不存在");
|
||||
// 如果有管理耳号,查询并设置羊只ID
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取羊只ID
|
||||
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
if (sheepId == null) {
|
||||
throw new ServiceException("无法获取羊只ID,请检查数据完整性");
|
||||
}
|
||||
scSheepDeath.setSheepId(sheepId);
|
||||
|
||||
// 检查该羊只是否已经有死淘记录
|
||||
ScSheepDeath existingDeath = new ScSheepDeath();
|
||||
existingDeath.setSheepId(sheepId);
|
||||
existingDeath.setIsDelete(0L); // 只查询未删除的记录
|
||||
List<ScSheepDeath> existingList = scSheepDeathMapper.selectScSheepDeathList(existingDeath);
|
||||
if (!existingList.isEmpty()) {
|
||||
throw new ServiceException("该羊只已存在死淘记录,不能重复添加");
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
scSheepDeath.setCreateTime(DateUtils.getNowDate());
|
||||
scSheepDeath.setIsDelete(0L);
|
||||
|
||||
// 插入死淘记录
|
||||
int result = scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
|
||||
|
||||
if (result > 0) {
|
||||
// 更新羊只状态为已死淘/已淘汰
|
||||
String newStatus = "死亡".equals(scSheepDeath.getEventType()) ? "已死淘" : "已淘汰";
|
||||
updateSheepStatus(sheepId, newStatus);
|
||||
}
|
||||
|
||||
return result;
|
||||
return scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,91 +126,18 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateScSheepDeath(ScSheepDeath scSheepDeath)
|
||||
{
|
||||
// 参数校验
|
||||
if (scSheepDeath.getId() == null) {
|
||||
throw new ServiceException("记录ID不能为空");
|
||||
}
|
||||
|
||||
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
|
||||
throw new ServiceException("管理耳号不能为空");
|
||||
}
|
||||
|
||||
// 获取原记录
|
||||
ScSheepDeath originalRecord = scSheepDeathMapper.selectScSheepDeathById(scSheepDeath.getId());
|
||||
if (originalRecord == null) {
|
||||
throw new ServiceException("原记录不存在");
|
||||
}
|
||||
|
||||
// 查询新的羊只信息并验证是否存在
|
||||
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags().trim());
|
||||
if (sheepInfo == null) {
|
||||
throw new ServiceException("管理耳号[" + scSheepDeath.getManageTags() + "]对应的羊只不存在");
|
||||
}
|
||||
|
||||
Long newSheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
|
||||
if (newSheepId == null) {
|
||||
throw new ServiceException("无法获取羊只ID,请检查数据完整性");
|
||||
}
|
||||
|
||||
// 如果更换了羊只,需要检查新羊只是否已有死淘记录
|
||||
if (!newSheepId.equals(originalRecord.getSheepId())) {
|
||||
ScSheepDeath checkDeath = new ScSheepDeath();
|
||||
checkDeath.setSheepId(newSheepId);
|
||||
checkDeath.setIsDelete(0L);
|
||||
List<ScSheepDeath> existingList = scSheepDeathMapper.selectScSheepDeathList(checkDeath);
|
||||
// 排除当前记录
|
||||
existingList = existingList.stream()
|
||||
.filter(death -> !death.getId().equals(scSheepDeath.getId()))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
if (!existingList.isEmpty()) {
|
||||
throw new ServiceException("新的羊只已存在其他死淘记录");
|
||||
// 如果管理耳号发生变化,重新查询并设置羊只ID
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
scSheepDeath.setSheepId(newSheepId);
|
||||
scSheepDeath.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
int result = scSheepDeathMapper.updateScSheepDeath(scSheepDeath);
|
||||
|
||||
if (result > 0) {
|
||||
// 如果更换了羊只,需要更新状态
|
||||
if (!newSheepId.equals(originalRecord.getSheepId())) {
|
||||
// 恢复原羊只状态(根据业务逻辑决定恢复到什么状态)
|
||||
updateSheepStatus(originalRecord.getSheepId(), "正常");
|
||||
|
||||
// 设置新羊只状态
|
||||
String newStatus = "死亡".equals(scSheepDeath.getEventType()) ? "已死淘" : "已淘汰";
|
||||
updateSheepStatus(newSheepId, newStatus);
|
||||
} else if (!originalRecord.getEventType().equals(scSheepDeath.getEventType())) {
|
||||
// 羊只没变,但事件类型改变,更新状态
|
||||
String newStatus = "死亡".equals(scSheepDeath.getEventType()) ? "已死淘" : "已淘汰";
|
||||
updateSheepStatus(newSheepId, newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新羊只状态
|
||||
*
|
||||
* @param sheepId 羊只ID
|
||||
* @param status 新状态
|
||||
*/
|
||||
private void updateSheepStatus(Long sheepId, String status) {
|
||||
try {
|
||||
// 直接通过现有mapper更新sheep_file表的状态
|
||||
// 这里需要在ScSheepDeathMapper中添加一个更新sheep_file状态的方法
|
||||
scSheepDeathMapper.updateSheepFileStatus(sheepId, status);
|
||||
} catch (Exception e) {
|
||||
// 记录日志但不影响主流程,因为死淘记录已经保存成功
|
||||
System.err.println("更新羊只状态失败: " + e.getMessage());
|
||||
// 在实际项目中应该使用日志框架记录
|
||||
// log.error("更新羊只状态失败, sheepId: {}, status: {}, error: {}", sheepId, status, e.getMessage());
|
||||
}
|
||||
return scSheepDeathMapper.updateScSheepDeath(scSheepDeath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,34 +147,9 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScSheepDeathByIds(Long[] ids)
|
||||
{
|
||||
if (ids == null || ids.length == 0) {
|
||||
throw new ServiceException("删除的记录ID不能为空");
|
||||
}
|
||||
|
||||
// 获取要删除的记录,用于恢复羊只状态
|
||||
List<ScSheepDeath> toDeleteRecords = new ArrayList<>();
|
||||
for (Long id : ids) {
|
||||
ScSheepDeath record = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
if (record != null) {
|
||||
toDeleteRecords.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
int result = scSheepDeathMapper.deleteScSheepDeathByIds(ids);
|
||||
|
||||
if (result > 0) {
|
||||
// 恢复对应羊只的状态
|
||||
for (ScSheepDeath record : toDeleteRecords) {
|
||||
if (record.getSheepId() != null) {
|
||||
updateSheepStatus(record.getSheepId(), "正常"); // 或者根据业务需要设置其他状态
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return scSheepDeathMapper.deleteScSheepDeathByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -289,23 +159,8 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScSheepDeathById(Long id)
|
||||
{
|
||||
if (id == null) {
|
||||
throw new ServiceException("删除的记录ID不能为空");
|
||||
}
|
||||
|
||||
// 获取要删除的记录
|
||||
ScSheepDeath record = scSheepDeathMapper.selectScSheepDeathById(id);
|
||||
|
||||
int result = scSheepDeathMapper.deleteScSheepDeathById(id);
|
||||
|
||||
if (result > 0 && record != null && record.getSheepId() != null) {
|
||||
// 恢复羊只状态
|
||||
updateSheepStatus(record.getSheepId(), "正常"); // 或者根据业务需要设置其他状态
|
||||
}
|
||||
|
||||
return result;
|
||||
return scSheepDeathMapper.deleteScSheepDeathById(id);
|
||||
}
|
||||
}
|
||||
@ -5,8 +5,12 @@ 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.domain.DaRanch;
|
||||
import com.zhyc.module.base.service.IBasSheepTypeService;
|
||||
import com.zhyc.module.base.service.IBasSheepVarietyService;
|
||||
import com.zhyc.module.base.service.IDaRanchService;
|
||||
import com.zhyc.module.produce.manage_sheep.domain.ScAddSheep;
|
||||
import com.zhyc.module.produce.manage_sheep.service.IScAddSheepService;
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
@ -36,6 +40,11 @@ public class ScAddSheepController {
|
||||
private IDaSheepfoldService daSheepfoldMapper;
|
||||
@Autowired
|
||||
private IBasSheepVarietyService basSheepVarietyMapper;
|
||||
@Autowired
|
||||
private IBasSheepTypeService basSheepTypeService;
|
||||
@Autowired
|
||||
private IDaRanchService daRanchService;
|
||||
|
||||
//新增羊只验证
|
||||
@PreAuthorize("@ss.hasPermi('produce:add_sheep:add')")
|
||||
@Log(title = "新增", businessType = BusinessType.INSERT)
|
||||
@ -44,6 +53,9 @@ public class ScAddSheepController {
|
||||
if (scAddSheep.getEarNumber() == null || scAddSheep.getEarNumber().isEmpty()) {
|
||||
return AjaxResult.error("耳号不能为空");
|
||||
}
|
||||
if (scAddSheep.getRanchId() == null || scAddSheep.getRanchId() == 0) {
|
||||
return AjaxResult.error("牧场不能为空");
|
||||
}
|
||||
if (scAddSheep.getSheepfold() == null || scAddSheep.getSheepfold() == 0) {
|
||||
return AjaxResult.error("羊舍不能为空");
|
||||
}
|
||||
@ -79,8 +91,15 @@ 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.getRanchId() != null) {
|
||||
// 根据牧场ID查询牧场信息
|
||||
DaRanch ranch = daRanchService.selectDaRanchById(scAddSheep.getRanchId().longValue());
|
||||
if (ranch != null) {
|
||||
scAddSheep.setRanchName(ranch.getRanch()); // 将牧场名称设置到实体中
|
||||
}
|
||||
}
|
||||
// 处理羊舍名称
|
||||
if (scAddSheep.getSheepfold() != null) {
|
||||
DaSheepfold fold = daSheepfoldMapper.selectDaSheepfoldById(scAddSheep.getSheepfold().longValue());
|
||||
if (fold != null) {
|
||||
@ -88,6 +107,7 @@ public class ScAddSheepController {
|
||||
}
|
||||
}
|
||||
|
||||
//处理羊只品种名称
|
||||
if (scAddSheep.getVarietyId() != null) {
|
||||
BasSheepVariety variety = basSheepVarietyMapper.selectBasSheepVarietyById(scAddSheep.getVarietyId().longValue());
|
||||
if (variety != null) {
|
||||
@ -95,9 +115,17 @@ 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, "羊只信息");
|
||||
}
|
||||
|
||||
//导入
|
||||
@PostMapping("/importData")
|
||||
@PreAuthorize("@ss.hasPermi('produce:add_sheep:import')")
|
||||
|
||||
@ -101,8 +101,8 @@ public class ScTransGroupController extends BaseController {
|
||||
/**
|
||||
* 审批转群记录
|
||||
*/
|
||||
@PutMapping("/approve")
|
||||
public AjaxResult approve(@RequestBody ScTransGroup scTransGroup) {
|
||||
return toAjax(scTransGroupService.approveScTransGroup(scTransGroup));
|
||||
}
|
||||
// @PutMapping("/approve")
|
||||
// public AjaxResult approve(@RequestBody ScTransGroup scTransGroup) {
|
||||
// return toAjax(scTransGroupService.approveScTransGroup(scTransGroup));
|
||||
// }
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -27,6 +27,11 @@ public class ScAddSheep extends BaseEntity {
|
||||
@Excel(name = "耳号")
|
||||
private String earNumber;
|
||||
|
||||
/** 牧场 */
|
||||
private Integer ranchId;
|
||||
@Excel(name = "牧场名称")
|
||||
private String ranchName;
|
||||
|
||||
/** 羊舍编号 */
|
||||
private Integer sheepfold;
|
||||
|
||||
@ -68,6 +73,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")
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
* 新备注
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
/**
|
||||
* 技术员
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
@ -70,4 +70,5 @@ public interface IScTransitionInfoService {
|
||||
|
||||
//审批转场
|
||||
public int approveScTransitionInfo(ScTransitionInfo scTransitionInfo);
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,11 @@ 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.domain.DaRanch;
|
||||
import com.zhyc.module.base.mapper.BasSheepVarietyMapper;
|
||||
import com.zhyc.module.base.service.IBasSheepTypeService;
|
||||
import com.zhyc.module.base.service.IDaRanchService;
|
||||
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 +36,11 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
@Autowired
|
||||
private BasSheepVarietyMapper basSheepVarietyMapper;
|
||||
|
||||
@Autowired
|
||||
private IBasSheepTypeService basSheepTypeService;
|
||||
|
||||
@Autowired
|
||||
private IDaRanchService daRanchService;
|
||||
//新增
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -47,6 +56,7 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
BasSheep bs = new BasSheep();
|
||||
bs.setManageTags(scAddSheep.getEarNumber());
|
||||
// bs.setElectronicTags(scAddSheep.getEarNumber());
|
||||
bs.setRanchId(scAddSheep.getRanchId().longValue());
|
||||
bs.setSheepfoldId(scAddSheep.getSheepfold().longValue());
|
||||
bs.setFatherId(null);
|
||||
bs.setMotherId(null);
|
||||
@ -64,7 +74,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 +114,23 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ScAddSheep sheep = list.get(i);
|
||||
try {
|
||||
// 处理品种名称转换为品种ID
|
||||
if (StringUtils.isBlank(sheep.getRanchName())) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第").append(i + 1).append("行:牧场名称不能为空");
|
||||
continue;
|
||||
}
|
||||
DaRanch ranchParam = new DaRanch();
|
||||
ranchParam.setRanch(sheep.getRanchName().trim());
|
||||
List<DaRanch> ranchList = daRanchService.selectDaRanchList(ranchParam);
|
||||
|
||||
if (ranchList == null || ranchList.isEmpty()) {
|
||||
failure++;
|
||||
failureMsg.append("<br/>第").append(i + 1)
|
||||
.append("行:牧场名称不存在【").append(sheep.getRanchName()).append("】");
|
||||
continue;
|
||||
}
|
||||
sheep.setRanchId(ranchList.get(0).getId().intValue());
|
||||
|
||||
if (StringUtils.isNotBlank(sheep.getVarietyName())) {
|
||||
Long varietyId = basSheepVarietyMapper.selectIdByName(sheep.getVarietyName());
|
||||
if (varietyId == null) {
|
||||
@ -122,10 +151,10 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 处理羊舍名称转换为羊舍ID
|
||||
if (StringUtils.isNotBlank(sheep.getSheepfoldNameExcel())) {
|
||||
DaSheepfold param = new DaSheepfold();
|
||||
param.setSheepfoldName(sheep.getSheepfoldNameExcel());
|
||||
param.setRanchId(sheep.getRanchId().longValue());
|
||||
List<DaSheepfold> foldList = daSheepfoldMapper.selectDaSheepfoldList(param);
|
||||
if (foldList == null || foldList.isEmpty()) {
|
||||
failure++;
|
||||
@ -139,7 +168,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 +193,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 核心校验:判断羊只基本信息表中是否存在未删除的同名耳号
|
||||
BasSheep existSheep = basSheepService.selectBasSheepByManageTags(sheep.getEarNumber().trim());
|
||||
if (existSheep != null) {
|
||||
failure++;
|
||||
@ -160,7 +204,6 @@ public class ScAddSheepServiceImpl implements IScAddSheepService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 执行导入(新增或更新)
|
||||
if (updateSupport && sheep.getId() != null) {
|
||||
sheep.setUpdateBy(operName);
|
||||
updateScAddSheep(sheep);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -70,11 +73,21 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertScTransGroup(ScTransGroup scTransGroup) {
|
||||
scTransGroup.setStatus(0);
|
||||
scTransGroup.setCreateTime(DateUtils.getNowDate());
|
||||
scTransGroup.setCreateBy(SecurityUtils.getUsername());
|
||||
return scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
int rows = scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
if (rows > 0) {
|
||||
try {
|
||||
updateSheepFold(scTransGroup);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("新增转群记录后更新羊舍失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
// return scTransGroupMapper.insertScTransGroup(scTransGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,9 +143,15 @@ public class ScTransGroupServiceImpl implements IScTransGroupService {
|
||||
* 更新羊只所在羊舍
|
||||
*/
|
||||
private void updateSheepFold(ScTransGroup transGroup) {
|
||||
Long foldTo = Long.valueOf(transGroup.getFoldTo());
|
||||
if (foldTo == null) {
|
||||
throw new RuntimeException("转入羊舍不能为空");
|
||||
Object foldToObj = transGroup.getFoldTo();
|
||||
if (foldToObj == null) {
|
||||
throw new RuntimeException("转入羊舍ID为空,请检查前端提交的foldTo参数");
|
||||
}
|
||||
Long foldTo;
|
||||
try {
|
||||
foldTo = Long.valueOf(foldToObj.toString());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("转入羊舍ID格式错误,应为数字,实际值:" + foldToObj);
|
||||
}
|
||||
|
||||
String manageTags = transGroup.getManageTags();
|
||||
@ -177,4 +196,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, "未知");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,12 @@ public class ScCastrate extends BaseEntity {
|
||||
@Excel(name = "耳号")
|
||||
private String manageTags;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@Excel(name = "事件类型")
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* 羊舍id
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
m.id,
|
||||
m.sheep_id,
|
||||
m.group_id,
|
||||
bsg.group_name,
|
||||
s.id AS bs_sheep_id,
|
||||
s.bs_manage_tags,
|
||||
s.variety,
|
||||
@ -47,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
s.family
|
||||
FROM bas_sheep_group_mapping m
|
||||
JOIN sheep_file s ON s.id = m.sheep_id
|
||||
JOIN bas_sheep_group bsg ON m.group_id = bsg.group_id
|
||||
<where>
|
||||
<if test="sheepId != null"> AND m.sheep_id = #{sheepId}</if>
|
||||
<if test="groupId != null"> AND m.group_id = #{groupId}</if>
|
||||
@ -125,4 +127,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
FROM bas_sheep_group_mapping
|
||||
WHERE group_id = #{groupId}
|
||||
</select>
|
||||
|
||||
<!-- 树形分组 -->
|
||||
<select id="selectGroupTree"
|
||||
resultType="com.zhyc.module.base.domain.BasGroupTreeVo">
|
||||
SELECT group_id AS groupId,
|
||||
group_name AS groupName,
|
||||
parent_id AS parentId
|
||||
FROM bas_sheep_group
|
||||
ORDER BY parent_id, group_id
|
||||
</select>
|
||||
</mapper>
|
||||
@ -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">
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
columns,
|
||||
comment
|
||||
from da_sheepfold
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
|
||||
@ -33,6 +34,10 @@
|
||||
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
|
||||
<if test="sheepfoldTypeId != null ">and sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||
</where>
|
||||
|
||||
order by
|
||||
SUBSTRING_INDEX(row_no, '-', 1),
|
||||
CAST(columns AS UNSIGNED)
|
||||
</select>
|
||||
|
||||
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
|
||||
|
||||
@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDewormById" parameterType="Long" resultMap="DewormResult">
|
||||
|
||||
@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="treatDay != null "> and treat_day = #{treatDay}</if>
|
||||
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDiagnosisById" parameterType="Long" resultMap="DiagnosisResult">
|
||||
|
||||
@ -28,16 +28,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</sql>
|
||||
|
||||
<select id="selectDisinfectList" parameterType="Disinfect" resultMap="DisinfectResult">
|
||||
<include refid="selectDisinfectVo"/>
|
||||
<where>
|
||||
<if test="sheepfoldId != null "> and sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="datetime != null "> and datetime = #{datetime}</if>
|
||||
<if test="technician != null and technician != ''"> and technician = #{technician}</if>
|
||||
<if test="way != null and way != ''"> and way = #{way}</if>
|
||||
<if test="usageId != null "> and usage_id = #{usageId}</if>
|
||||
<if test="ratio != null and ratio != ''"> and ratio = #{ratio}</if>
|
||||
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
|
||||
</where>
|
||||
SELECT sd.id,
|
||||
sd.sheepfold_id,
|
||||
sd.datetime,
|
||||
sd.technician,
|
||||
sd.way,
|
||||
sd.usage_id,
|
||||
sd.ratio,
|
||||
sd.comment,
|
||||
sd.update_by,
|
||||
sd.update_time,
|
||||
sd.create_by,
|
||||
sd.create_time,
|
||||
ds.sheepfold_name
|
||||
FROM sw_disinfect sd
|
||||
LEFT JOIN da_sheepfold ds ON ds.id = sd.sheepfold_id
|
||||
WHERE 1 = 1
|
||||
<if test="sheepfoldId != null"> AND sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="datetime != null"> AND sd.datetime = #{datetime}</if>
|
||||
<if test="technician != null and technician != ''"> AND sd.technician = #{technician}</if>
|
||||
<if test="way != null and way != ''"> AND sd.way = #{way}</if>
|
||||
<if test="usageId != null"> AND sd.usage_id = #{usageId}</if>
|
||||
<if test="ratio != null and ratio != ''"> AND sd.ratio = #{ratio}</if>
|
||||
<if test="comment != null and comment != ''"> AND sd.comment = #{comment}</if>
|
||||
<!-- 子表过滤条件:仅保留满足药品名称的记录 -->
|
||||
<if test="mediName != null and mediName != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sw_medicine_usage_details mud
|
||||
JOIN sw_medicine sm ON sm.id = mud.medi_id
|
||||
WHERE mud.medi_usage = sd.usage_id
|
||||
AND sm.name like concat('%',#{mediName},'%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY datetime DESC
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectDisinfectById" parameterType="Long" resultMap="DisinfectResult">
|
||||
@ -71,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where sd.id = #{id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDisinfectById" parameterType="Long">
|
||||
|
||||
@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="datetime != null "> and datetime = #{datetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectHealthById" parameterType="Long" resultMap="HealthResult">
|
||||
|
||||
@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectImmunityById" parameterType="Long" resultMap="ImmunityResult">
|
||||
|
||||
@ -30,11 +30,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectQuarantineReportVo">
|
||||
select sqr.id, sheep_type,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status,
|
||||
select sqr.id, sheep_type,sqr.gender,sqr.parity,sqr.breed,sqr.month_age,sheep_id, datetime, quar_item, sample_type, sampler, quar_officer, result, status,
|
||||
sqr.update_by, sqr.update_time, sqr.create_by, sqr.create_time,
|
||||
sqi.name as item_name,
|
||||
sqs.name as sample,
|
||||
sf.bs_manage_tags sheep_no,sf.gender,sf.parity,sf.breed,sf.month_age
|
||||
sf.bs_manage_tags sheep_no
|
||||
from sw_quarantine_report sqr
|
||||
left join sw_quarantine_items sqi on sqr.quar_item = sqi.id
|
||||
left join sw_quarantine_sample sqs on sqr.sample_type = sqs.id
|
||||
@ -48,10 +48,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="quarItem != null "> and quar_item = #{quarItem}</if>
|
||||
<if test="sampleType != null "> and sample_type = #{sampleType}</if>
|
||||
<if test="sampler != null and sampler != ''"> and sampler = #{sampler}</if>
|
||||
<if test="quarOfficer != null and quarOfficer != ''"> and quar_officer = #{quarOfficer}</if>
|
||||
<if test="sampler != null and sampler != ''"> and sampler like concat('%',#{sampler},'%') </if>
|
||||
<if test="quarOfficer != null and quarOfficer != ''"> and quar_officer like concat('%',#{quarOfficer},'%')</if>
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join sw_quarantine_sample sqs on sqr.sample_type = sqs.id
|
||||
left join sheep_file sf on sqr.sheep_id = sf.id
|
||||
where sqr.id = #{id}
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertQuarantineReport" parameterType="java.util.List">
|
||||
|
||||
@ -7,6 +7,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="SwMedicineUsage" id="SwMedicineUsageResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="sheepfoldId" column="sheepfold_id"/>
|
||||
<result property="sheepfoldName" column="sheepfold_name"/>
|
||||
<result property="sheepId" column="sheep_id"/>
|
||||
<result property="sheepNo" column="sheep_no"/>
|
||||
<result property="datetime" column="datetime"/>
|
||||
<result property="useType" column="use_type" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
@ -31,7 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSwMedicineUsageVo">
|
||||
select id, name, use_type, update_by, update_time, create_by, create_time from sw_medicine_usage
|
||||
select smu.id, sheepfold as sheepfold_id,sheep sheep_id,name, datetime,use_type, smu.update_by, smu.update_time, smu.create_by, smu.create_time,
|
||||
ds.sheepfold_name,
|
||||
bs.manage_tags sheep_no
|
||||
from sw_medicine_usage smu
|
||||
left join da_sheepfold ds on ds.id = smu.sheepfold
|
||||
left join bas_sheep bs on bs.id = smu.sheep
|
||||
</sql>
|
||||
|
||||
<select id="selectSwMedicineUsageList" parameterType="SwMedicineUsage" resultMap="SwMedicineUsageResult">
|
||||
@ -39,8 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="useType != null and useType != ''"> and use_type = #{useType}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
<if test="sheepNo != null and sheepNo != ''"> and bs.manage_tags like concat('%', #{sheepNo}, '%')</if>
|
||||
<if test="params.beginUseTime != null and params.beginUseTime != '' and params.endUseTime != null and params.endUseTime != ''"> and smu.datetime between #{params.beginUseTime} and #{params.endUseTime}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and smu.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and smu.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectSwMedicineUsageById" parameterType="Integer" resultMap="SwMedicineUsageSwMedicineUsageDetailsResult">
|
||||
@ -55,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from sw_medicine_usage_details smud
|
||||
join sw_medicine sm on smud.medi_id = sm.id
|
||||
where medi_usage = #{medi_usage}
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertSwMedicineUsage" parameterType="SwMedicineUsage" useGeneratedKeys="true" keyProperty="id">
|
||||
@ -62,6 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="useType != null">use_type,</if>
|
||||
<if test="sheepfoldId != null">sheepfold,</if>
|
||||
<if test="sheepId != null">sheep,</if>
|
||||
<if test="datetime != null">datetime,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@ -70,6 +87,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="useType != null">#{useType},</if>
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="sheepId != null">#{sheepId},</if>
|
||||
<if test="datetime != null">#{datetime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
|
||||
@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
|
||||
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
</select>
|
||||
|
||||
<select id="selectTreatmentById" parameterType="Long" resultMap="TreatmentResult">
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.feed.mapper.SgFeedListMapper">
|
||||
|
||||
<resultMap type="SgFeedList" id="SgFeedListResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="formulaId" column="formula_id" />
|
||||
<result property="formulaBatchId" column="formula_batch_id" />
|
||||
<result property="zookeeper" column="zookeeper" />
|
||||
<result property="deployDate" column="deploy_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSgFeedListVo">
|
||||
select id, formula_id, formula_batch_id, zookeeper, deploy_date from sg_feed_list
|
||||
</sql>
|
||||
|
||||
<select id="selectSgFeedListList" parameterType="SgFeedList" resultMap="SgFeedListResult">
|
||||
<include refid="selectSgFeedListVo"/>
|
||||
<where>
|
||||
<if test="formulaId != null and formulaId != ''"> and formula_id = #{formulaId}</if>
|
||||
<if test="zookeeper != null and zookeeper != ''"> and zookeeper = #{zookeeper}</if>
|
||||
<if test="deployDate != null "> and deploy_date = #{deployDate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSgFeedListById" parameterType="Long" resultMap="SgFeedListResult">
|
||||
<include refid="selectSgFeedListVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSgFeedList" parameterType="SgFeedList" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sg_feed_list
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id,</if>
|
||||
<if test="formulaBatchId != null">formula_batch_id,</if>
|
||||
<if test="zookeeper != null">zookeeper,</if>
|
||||
<if test="deployDate != null">deploy_date,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="formulaId != null">#{formulaId},</if>
|
||||
<if test="formulaBatchId != null">#{formulaBatchId},</if>
|
||||
<if test="zookeeper != null">#{zookeeper},</if>
|
||||
<if test="deployDate != null">#{deployDate},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgFeedList" parameterType="SgFeedList">
|
||||
update sg_feed_list
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formulaId != null">formula_id = #{formulaId},</if>
|
||||
<if test="formulaBatchId != null">formula_batch_id = #{formulaBatchId},</if>
|
||||
<if test="zookeeper != null">zookeeper = #{zookeeper},</if>
|
||||
<if test="deployDate != null">deploy_date = #{deployDate},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSgFeedListById" parameterType="Long">
|
||||
delete from sg_feed_list where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgFeedListByIds" parameterType="String">
|
||||
delete from sg_feed_list where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -102,6 +102,7 @@
|
||||
and sm.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sm.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBodyMeasureById" parameterType="Long" resultMap="ScBodyMeasureResult">
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbs.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBodyScoreById" parameterType="Long" resultMap="ScBodyScoreResult">
|
||||
|
||||
@ -56,6 +56,7 @@
|
||||
and sbr.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sbr.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScBreastRatingById" parameterType="Long" resultMap="ScBreastRatingResult">
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -54,18 +61,19 @@
|
||||
|
||||
<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})
|
||||
(ear_number, sheepfold, ranch_id, father, mother, born_weight, birthday,
|
||||
gender, parity, variety_id, type_id, join_date, comment, technician,
|
||||
create_by, create_time)
|
||||
VALUES (#{earNumber}, #{sheepfold}, #{ranchId}, #{father}, #{mother}, #{bornWeight},
|
||||
#{birthday}, #{gender}, #{parity}, #{varietyId}, #{typeId}, #{joinDate},
|
||||
#{comment}, #{technician}, #{createBy}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateScAddSheep" parameterType="ScAddSheep">
|
||||
UPDATE sc_add_sheep
|
||||
<set>
|
||||
ear_number = #{earNumber},
|
||||
ranch_id = #{ranchId},
|
||||
sheepfold = #{sheepfold},
|
||||
father = #{father},
|
||||
mother = #{mother},
|
||||
@ -74,6 +82,7 @@
|
||||
gender = #{gender},
|
||||
parity = #{parity},
|
||||
variety_id = #{varietyId},
|
||||
type_id = #{typeId},
|
||||
join_date = #{joinDate},
|
||||
comment = #{comment},
|
||||
technician = #{technician},
|
||||
|
||||
@ -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>
|
||||
@ -43,6 +49,7 @@
|
||||
and scc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scc.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeCommentById" parameterType="Long" resultMap="ScChangeCommentResult">
|
||||
|
||||
@ -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}, '%')
|
||||
@ -48,6 +61,7 @@
|
||||
and sce.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sce.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeEarById" parameterType="Integer" resultMap="ScChangeEarResult">
|
||||
|
||||
@ -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>
|
||||
@ -46,6 +52,7 @@
|
||||
and scv.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY scv.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScChangeVarietyById" parameterType="Integer" resultMap="ScChangeVarietyResult">
|
||||
|
||||
@ -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,14 +58,20 @@
|
||||
<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>
|
||||
</where>
|
||||
ORDER BY tg.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
@ -75,6 +85,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 +99,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 +117,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>
|
||||
|
||||
@ -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>
|
||||
@ -55,6 +67,7 @@
|
||||
and t.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScTransitionInfoById" parameterType="Integer" resultMap="ScTransitionInfoResult">
|
||||
@ -69,7 +82,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 +96,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 +110,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 +127,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>
|
||||
|
||||
@ -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,
|
||||
@ -50,6 +52,7 @@
|
||||
and sc.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sc.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScCastrateById" parameterType="Long" resultMap="ScCastrateResult">
|
||||
|
||||
@ -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,
|
||||
@ -46,6 +48,7 @@
|
||||
and bs.manage_tags like concat('%', #{manageTags}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY fh.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectScFixHoofById" parameterType="java.lang.Integer" resultMap="ScFixHoofResult">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user