羊只分组页面下拉框调整为嵌套查询,羊舍管理添加可视化
This commit is contained in:
parent
80d82c031f
commit
9183e99413
@ -1,12 +1,15 @@
|
|||||||
package com.zhyc.module.base.controller;
|
package com.zhyc.module.base.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.zhyc.common.core.domain.entity.SysDictData;
|
||||||
import com.zhyc.common.utils.StringUtils;
|
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.BasSheepGroupMapping;
|
||||||
|
import com.zhyc.module.base.domain.BasSheepGroupExportVo;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -22,6 +25,13 @@ import com.zhyc.common.core.page.TableDataInfo;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Date;
|
||||||
|
// 1. 引入若依字典工具
|
||||||
|
import com.zhyc.common.utils.DictUtils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 羊只分组关联Controller
|
* 羊只分组关联Controller
|
||||||
@ -33,6 +43,20 @@ import org.slf4j.LoggerFactory;
|
|||||||
@RequestMapping("/sheep_grouping/sheep_grouping")
|
@RequestMapping("/sheep_grouping/sheep_grouping")
|
||||||
public class BasSheepGroupMappingController extends BaseController
|
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
|
@Autowired
|
||||||
private IBasSheepGroupMappingService basSheepGroupMappingService;
|
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')")
|
@PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:export')")
|
||||||
@Log(title = "羊只分组关联", businessType = BusinessType.EXPORT)
|
@Log(title = "羊只分组关联", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, BasSheepGroupMapping basSheepGroupMapping)
|
public void exportJoin(HttpServletResponse response,
|
||||||
{
|
@RequestParam(required = false) Long sheepId,
|
||||||
List<BasSheepGroupMapping> list = basSheepGroupMappingService.selectBasSheepGroupMappingList(basSheepGroupMapping);
|
@RequestParam(required = false) Long groupId,
|
||||||
ExcelUtil<BasSheepGroupMapping> util = new ExcelUtil<BasSheepGroupMapping>(BasSheepGroupMapping.class);
|
@RequestParam(required = false) String bsManageTags) throws IOException {
|
||||||
util.exportExcel(response, list, "羊只分组关联数据");
|
|
||||||
|
// 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 org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import com.zhyc.common.utils.DictUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 羊舍管理Controller
|
* 羊舍管理Controller
|
||||||
@ -119,4 +123,73 @@ public class DaSheepfoldController extends BaseController
|
|||||||
boolean exist = daSheepfoldService.checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo);
|
boolean exist = daSheepfoldService.checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo);
|
||||||
return AjaxResult.success(exist);
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -33,4 +33,13 @@ public class BasSheepGroupMapping extends BaseEntity
|
|||||||
@Excel(name = "分组ID")
|
@Excel(name = "分组ID")
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
|
@Excel(name = "耳号")
|
||||||
|
private String bsManageTags; // 或者 List<String>、其他类型
|
||||||
|
public String getBsManageTags() {
|
||||||
|
return bsManageTags;
|
||||||
|
}
|
||||||
|
public void setBsManageTags(String bsManageTags) {
|
||||||
|
this.bsManageTags = bsManageTags;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,70 @@ public class DaSheepfold extends BaseEntity
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
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 */
|
/** 羊舍id */
|
||||||
@Excel(name = "羊舍id")
|
@Excel(name = "羊舍id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.zhyc.module.base.domain.BasSheepGroupMapping;
|
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.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
/**
|
/**
|
||||||
@ -85,4 +86,6 @@ public interface BasSheepGroupMappingMapper
|
|||||||
|
|
||||||
List<BasSheepGroupMapping> selectListByGroupId(@Param("groupId") Long groupId);
|
List<BasSheepGroupMapping> selectListByGroupId(@Param("groupId") Long groupId);
|
||||||
|
|
||||||
|
List<BasGroupTreeVo> selectGroupTree();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.zhyc.common.core.domain.AjaxResult;
|
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.domain.BasSheepGroupMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,4 +71,9 @@ public interface IBasSheepGroupMappingService
|
|||||||
public int deleteBasSheepGroupMappingById(Long id);
|
public int deleteBasSheepGroupMappingById(Long id);
|
||||||
|
|
||||||
public AjaxResult addByEarTags(List<String> earTags, Long groupId);
|
public AjaxResult addByEarTags(List<String> earTags, Long groupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 树形分组下拉框
|
||||||
|
*/
|
||||||
|
List<BasGroupTreeVo> selectGroupTree();
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.zhyc.common.core.domain.AjaxResult;
|
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.domain.BasSheepGroupMapping;
|
||||||
import com.zhyc.module.base.mapper.BasSheepGroupMappingMapper;
|
import com.zhyc.module.base.mapper.BasSheepGroupMappingMapper;
|
||||||
import com.zhyc.module.base.service.IBasSheepGroupMappingService;
|
import com.zhyc.module.base.service.IBasSheepGroupMappingService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 羊只分组关联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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
m.id,
|
m.id,
|
||||||
m.sheep_id,
|
m.sheep_id,
|
||||||
m.group_id,
|
m.group_id,
|
||||||
|
bsg.group_name,
|
||||||
s.id AS bs_sheep_id,
|
s.id AS bs_sheep_id,
|
||||||
s.bs_manage_tags,
|
s.bs_manage_tags,
|
||||||
s.variety,
|
s.variety,
|
||||||
@ -47,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
s.family
|
s.family
|
||||||
FROM bas_sheep_group_mapping m
|
FROM bas_sheep_group_mapping m
|
||||||
JOIN sheep_file s ON s.id = m.sheep_id
|
JOIN sheep_file s ON s.id = m.sheep_id
|
||||||
|
JOIN bas_sheep_group bsg ON m.group_id = bsg.group_id
|
||||||
<where>
|
<where>
|
||||||
<if test="sheepId != null"> AND m.sheep_id = #{sheepId}</if>
|
<if test="sheepId != null"> AND m.sheep_id = #{sheepId}</if>
|
||||||
<if test="groupId != null"> AND m.group_id = #{groupId}</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
|
FROM bas_sheep_group_mapping
|
||||||
WHERE group_id = #{groupId}
|
WHERE group_id = #{groupId}
|
||||||
</select>
|
</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>
|
</mapper>
|
@ -25,6 +25,7 @@
|
|||||||
columns,
|
columns,
|
||||||
comment
|
comment
|
||||||
from da_sheepfold
|
from da_sheepfold
|
||||||
|
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
|
<select id="selectDaSheepfoldList" parameterType="DaSheepfold" resultMap="DaSheepfoldResult">
|
||||||
@ -33,6 +34,10 @@
|
|||||||
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
|
<if test="ranchId != null ">and ranch_id = #{ranchId}</if>
|
||||||
<if test="sheepfoldTypeId != null ">and sheepfold_type_id = #{sheepfoldTypeId}</if>
|
<if test="sheepfoldTypeId != null ">and sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
|
order by
|
||||||
|
SUBSTRING_INDEX(row_no, '-', 1),
|
||||||
|
CAST(columns AS UNSIGNED)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
|
<select id="selectDaSheepfoldById" parameterType="Long" resultMap="DaSheepfoldResult">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user