Merge remote-tracking branch 'origin/main'

This commit is contained in:
zyk
2026-03-05 14:58:21 +08:00
19 changed files with 206 additions and 186 deletions

View File

@@ -84,6 +84,11 @@ public class BasSheepController extends BaseController {
@Log(title = "羊只基本信息", businessType = BusinessType.INSERT) @Log(title = "羊只基本信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody BasSheep basSheep) { public AjaxResult add(@RequestBody BasSheep basSheep) {
// 新增下面这两行从当前登录态中获取部门ID和用户ID并赋值给即将保存的实体
basSheep.setDeptId(getDeptId());
basSheep.setUserId(getUserId());
return toAjax(basSheepService.insertBasSheep(basSheep)); return toAjax(basSheepService.insertBasSheep(basSheep));
} }

View File

@@ -69,6 +69,10 @@ public class BasSheepGroupController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody BasSheepGroup basSheepGroup) public AjaxResult add(@RequestBody BasSheepGroup basSheepGroup)
{ {
// 👇 新增这两行赋值语句
basSheepGroup.setDeptId(getDeptId());
basSheepGroup.setUserId(getUserId());
return toAjax(basSheepGroupService.insertBasSheepGroup(basSheepGroup)); return toAjax(basSheepGroupService.insertBasSheepGroup(basSheepGroup));
} }

View File

@@ -166,6 +166,10 @@ public class DaSheepfoldController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody DaSheepfold daSheepfold) public AjaxResult add(@RequestBody DaSheepfold daSheepfold)
{ {
// 👇 新增这两行赋值语句
daSheepfold.setDeptId(getDeptId());
daSheepfold.setUserId(getUserId());
return toAjax(daSheepfoldService.insertDaSheepfold(daSheepfold)); return toAjax(daSheepfoldService.insertDaSheepfold(daSheepfold));
} }

View File

@@ -209,62 +209,34 @@ public class SheepFileController extends BaseController
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, HttpServletRequest request) public void export(HttpServletResponse response, HttpServletRequest request)
{ {
// 构建查询条件对象
SheepFile sheepFile = new SheepFile(); SheepFile sheepFile = new SheepFile();
Map<String, Object> customParams = new HashMap<>(); Map<String, Object> customParams = new HashMap<>();
// 解析所有请求参数
Map<String, String[]> parameterMap = request.getParameterMap(); Map<String, String[]> parameterMap = request.getParameterMap();
// 1. 更直接地获取前端参数
String exportIdsStr = request.getParameter("exportIds");
String visibleColumnsStr = request.getParameter("visibleColumns");
// 2. 遍历其他条件
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) { for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] values = entry.getValue(); String[] values = entry.getValue();
if (values != null && values.length > 0 && StringUtils.isNotBlank(values[0])) { if (values != null && values.length > 0 && StringUtils.isNotBlank(values[0])) {
String value = values[0]; String value = values[0];
// 使用若依框架的工具方法处理参数
switch (key) { switch (key) {
// --- 单值参数 --- case "bsManageTags": sheepFile.setBsManageTags(convertToString(value)); break;
case "bsManageTags": case "electronicTags": sheepFile.setElectronicTags(convertToString(value)); break;
sheepFile.setBsManageTags(convertToString(value)); case "drRanch": sheepFile.setDrRanch(convertToString(value)); break;
break; case "variety": sheepFile.setVariety(convertToString(value)); break;
case "electronicTags": case "name": sheepFile.setName(convertToString(value)); break;
sheepFile.setElectronicTags(convertToString(value)); case "gender": sheepFile.setGender(Convert.toLong(value)); break;
break; case "statusId": sheepFile.setStatusId(Convert.toLong(value)); break;
case "drRanch": case "breed": sheepFile.setBreed(convertToString(value)); break;
sheepFile.setDrRanch(convertToString(value)); case "allEarNumbers": sheepFile.setAllEarNumbers(new ArrayList<>(Arrays.asList(values))); break;
break; case "allEleEarNumbers": sheepFile.setAllEleEarNumbers(new ArrayList<>(Arrays.asList(values))); break;
case "variety": case "allBreedingStatus": sheepFile.setAllBreedingStatus(new ArrayList<>(Arrays.asList(values))); break;
sheepFile.setVariety(convertToString(value)); case "allSheepTypes": sheepFile.setAllSheepTypes(new ArrayList<>(Arrays.asList(values))); break;
break;
case "name":
sheepFile.setName(convertToString(value));
break;
case "gender":
sheepFile.setGender(Convert.toLong(value));
break;
case "statusId":
sheepFile.setStatusId(Convert.toLong(value));
break;
case "breed":
sheepFile.setBreed(convertToString(value));
break;
// --- 新增:处理多选数组参数 ---
// request.getParameterMap 中的值本身就是 String[],可以直接使用
case "allEarNumbers":
sheepFile.setAllEarNumbers(new ArrayList<>(Arrays.asList(values)));
break;
case "allEleEarNumbers":
sheepFile.setAllEleEarNumbers(new ArrayList<>(Arrays.asList(values)));
break;
case "allBreedingStatus":
sheepFile.setAllBreedingStatus(new ArrayList<>(Arrays.asList(values)));
break;
case "allSheepTypes":
sheepFile.setAllSheepTypes(new ArrayList<>(Arrays.asList(values)));
break;
case "allGenders": case "allGenders":
List<Long> genderList = new ArrayList<>(); List<Long> genderList = new ArrayList<>();
for(String v : values){ for(String v : values){
@@ -273,24 +245,50 @@ public class SheepFileController extends BaseController
} }
sheepFile.setAllGenders(genderList); sheepFile.setAllGenders(genderList);
break; break;
case "pageNum": case "pageSize": case "exportIds": case "visibleColumns":
case "pageNum": break; // 忽略这些非数据库实体的字段
case "pageSize":
// 忽略分页参数
break;
default: default:
// 自定义参数
customParams.put(key, value); customParams.put(key, value);
break; break;
} }
} }
} }
// 调用Service获取数据 // 3. 获取数据并执行行过滤
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile); List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile);
if (StringUtils.isNotBlank(exportIdsStr)) {
List<String> exportIdList = Arrays.asList(exportIdsStr.split(","));
list = list.stream()
.filter(item -> exportIdList.contains(String.valueOf(item.getId())))
.collect(java.util.stream.Collectors.toList());
}
// 使用若依框架的Excel工具类导出 // 4. 执行列过滤
ExcelUtil<SheepFile> util = new ExcelUtil<>(SheepFile.class); ExcelUtil<SheepFile> util = new ExcelUtil<>(SheepFile.class);
if (StringUtils.isNotBlank(visibleColumnsStr)) {
// 清理字符串可能的空格并转为List
List<String> visibleColumns = Arrays.asList(visibleColumnsStr.split("\\s*,\\s*"));
List<String> colsToHide = new ArrayList<>();
Class<?> clazz = SheepFile.class;
while (clazz != null) {
for (java.lang.reflect.Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(com.zhyc.common.annotation.Excel.class)) {
if (!visibleColumns.contains(field.getName())) {
colsToHide.add(field.getName());
}
}
}
clazz = clazz.getSuperclass();
}
// 【核心修复】一次性把所有的字段数组传进去,规避若依底层循环覆盖的 Bug
if (!colsToHide.isEmpty()) {
util.hideColumn(colsToHide.toArray(new String[0]));
}
}
util.exportExcel(response, list, "羊只档案数据"); util.exportExcel(response, list, "羊只档案数据");
} }

View File

@@ -189,4 +189,11 @@ public class BasSheep extends BaseEntity
private Long isDelete; private Long isDelete;
/** 用户编号 */
private Long userId;
/** 部门编号 */
private Long deptId;
} }

View File

@@ -42,4 +42,24 @@ public class BasSheepGroup extends TreeEntity
private Integer isLeaf; private Integer isLeaf;
// 新增数据隔离字段
/** 用户编号 */
private Long userId;
/** 部门编号 */
private Long deptId;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
} }

View File

@@ -121,4 +121,26 @@ public class DaSheepfold extends BaseEntity
private Integer totalSheepCount; private Integer totalSheepCount;
// 👇 新增数据隔离字段
/** 用户编号 */
private Long userId;
/** 部门编号 */
private Long deptId;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
} }

View File

@@ -319,4 +319,10 @@ public class SheepFile extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createTime; private Date createTime;
/** 用户编号 */
private Long userId;
/** 部门编号 */
private Long deptId;
} }

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.exception.ServiceException; import com.zhyc.common.exception.ServiceException;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.base.domain.BasSheepGroup; import com.zhyc.module.base.domain.BasSheepGroup;
@@ -45,6 +46,7 @@ public class BasSheepGroupServiceImpl implements IBasSheepGroupService
// { // {
// return basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup); // return basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
// } // }
@DataScope(deptAlias = "g", userAlias = "g")
@Override @Override
public List<BasSheepGroup> selectBasSheepGroupList(BasSheepGroup basSheepGroup) { public List<BasSheepGroup> selectBasSheepGroupList(BasSheepGroup basSheepGroup) {
List<BasSheepGroup> groups = basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup); List<BasSheepGroup> groups = basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
@@ -122,6 +124,7 @@ public class BasSheepGroupServiceImpl implements IBasSheepGroupService
return basSheepGroupMapper.deleteBasSheepGroupByGroupId(groupId); return basSheepGroupMapper.deleteBasSheepGroupByGroupId(groupId);
} }
@DataScope(deptAlias = "g", userAlias = "g")
@Override @Override
public List<BasSheepGroup> selectLeafNodes() { public List<BasSheepGroup> selectLeafNodes() {
List<BasSheepGroup> leafNodes = basSheepGroupMapper.selectLeafNodes(); List<BasSheepGroup> leafNodes = basSheepGroupMapper.selectLeafNodes();

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold; import com.zhyc.module.base.domain.DaSheepfold;
@@ -50,6 +51,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
* @param daSheepfold 羊舍管理 * @param daSheepfold 羊舍管理
* @return 羊舍管理 * @return 羊舍管理
*/ */
@DataScope(deptAlias = "ds", userAlias = "ds")
@Override @Override
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold) public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
{ {
@@ -60,6 +62,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
/** /**
* 羊舍级别汇总查询(主表格) * 羊舍级别汇总查询(主表格)
*/ */
@DataScope(deptAlias = "ds", userAlias = "ds")
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) { public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold); return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
} }

View File

@@ -1,5 +1,7 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
// 新增这一行导入
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.base.domain.BreedRamFile; import com.zhyc.module.base.domain.BreedRamFile;
import com.zhyc.module.base.domain.SheepFile; import com.zhyc.module.base.domain.SheepFile;
import com.zhyc.module.base.mapper.SheepFileMapper; import com.zhyc.module.base.mapper.SheepFileMapper;
@@ -38,6 +40,7 @@ public class SheepFileServiceImpl implements ISheepFileService {
/** /**
* 查询羊只档案列表 * 查询羊只档案列表
*/ */
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<SheepFile> selectSheepFileList(SheepFile sheepFile) { public List<SheepFile> selectSheepFileList(SheepFile sheepFile) {
return sheepFileMapper.selectSheepFileList(sheepFile); return sheepFileMapper.selectSheepFileList(sheepFile);
@@ -56,26 +59,31 @@ public class SheepFileServiceImpl implements ISheepFileService {
return sheepFileMapper.selectSheepByManageTags(tags); return sheepFileMapper.selectSheepByManageTags(tags);
} }
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<Map<String, Object>> countBySheepType() { public List<Map<String, Object>> countBySheepType() {
return sheepFileMapper.countBySheepType(); return sheepFileMapper.countBySheepType();
} }
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<Map<String, Object>> countByBreedStatus() { public List<Map<String, Object>> countByBreedStatus() {
return sheepFileMapper.countByBreedStatus(); return sheepFileMapper.countByBreedStatus();
} }
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<Map<String, Object>> countByVariety() { public List<Map<String, Object>> countByVariety() {
return sheepFileMapper.countByVariety(); return sheepFileMapper.countByVariety();
} }
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<Map<String, Object>> countParityOfLactation() { public List<Map<String, Object>> countParityOfLactation() {
return sheepFileMapper.countParityOfLactation(); return sheepFileMapper.countParityOfLactation();
} }
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public Long countInGroup() { return sheepFileMapper.countInGroup(); } public Long countInGroup() { return sheepFileMapper.countInGroup(); }
@@ -100,6 +108,7 @@ public class SheepFileServiceImpl implements ISheepFileService {
* 必须调用 Mapper 中对应的 XML 方法 (selectSheepFileListByCondition) * 必须调用 Mapper 中对应的 XML 方法 (selectSheepFileListByCondition)
* 并且传递 sheepFile 对象以启用 <foreach> 列表查询 * 并且传递 sheepFile 对象以启用 <foreach> 列表查询
*/ */
@DataScope(deptAlias = "sf", userAlias = "sf")
@Override @Override
public List<SheepFile> selectSheepFileListByCondition(Map<String, Object> params, SheepFile sheepFile) { public List<SheepFile> selectSheepFileListByCondition(Map<String, Object> params, SheepFile sheepFile) {
// 1. 验证并处理自定义参数 (驼峰转下划线、安全检查) // 1. 验证并处理自定义参数 (驼峰转下划线、安全检查)

View File

@@ -84,6 +84,9 @@ public class DdSaleController extends BaseController {
@Log(title = "销售主单", businessType = BusinessType.INSERT) @Log(title = "销售主单", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody DdSale ddSale) { public AjaxResult add(@RequestBody DdSale ddSale) {
// 适配数据分离
ddSale.setDeptId(getDeptId());
ddSale.setUserId(getUserId());
return toAjax(ddSaleService.insertDdSale(ddSale)); return toAjax(ddSaleService.insertDdSale(ddSale));
} }

View File

@@ -4,6 +4,10 @@ import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
@@ -15,6 +19,8 @@ import com.zhyc.common.core.domain.BaseEntity;
* @author HashMap * @author HashMap
* @date 2025-12-01 * @date 2025-12-01
*/ */
@EqualsAndHashCode(callSuper = true)
@Data
public class DdSale extends BaseEntity public class DdSale extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -59,119 +65,11 @@ public class DdSale extends BaseEntity
@Excel(name = "技术员") @Excel(name = "技术员")
private String tech; private String tech;
private Long userId;
private Long deptId;
/** 销售明细信息 */ /** 销售明细信息 */
private List<DdSaleItem> ddSaleItemList; private List<DdSaleItem> ddSaleItemList;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setSaleDate(Date saleDate)
{
this.saleDate = saleDate;
}
public Date getSaleDate()
{
return saleDate;
}
public void setCustName(String custName)
{
this.custName = custName;
}
public String getCustName()
{
return custName;
}
public void setCustPhone(String custPhone)
{
this.custPhone = custPhone;
}
public String getCustPhone()
{
return custPhone;
}
public void setCustAddr(String custAddr)
{
this.custAddr = custAddr;
}
public String getCustAddr()
{
return custAddr;
}
public void setSalesper(String salesper)
{
this.salesper = salesper;
}
public String getSalesper()
{
return salesper;
}
public void setQuaranNo(String quaranNo)
{
this.quaranNo = quaranNo;
}
public String getQuaranNo()
{
return quaranNo;
}
public void setApprNo(String apprNo)
{
this.apprNo = apprNo;
}
public String getApprNo()
{
return apprNo;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setTech(String tech)
{
this.tech = tech;
}
public String getTech()
{
return tech;
}
public List<DdSaleItem> getDdSaleItemList()
{
return ddSaleItemList;
}
public void setDdSaleItemList(List<DdSaleItem> ddSaleItemList)
{
this.ddSaleItemList = ddSaleItemList;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.frozen.service.impl;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.frozen.domain.DdFe; import com.zhyc.module.frozen.domain.DdFe;
import com.zhyc.module.frozen.domain.DdFs; import com.zhyc.module.frozen.domain.DdFs;
@@ -58,6 +59,7 @@ public class DdSaleServiceImpl implements IDdSaleService {
* @return 销售主单 * @return 销售主单
*/ */
@Override @Override
@DataScope(deptAlias = "dd_sl_alias" , userAlias = "dd_sl_alias")
public List<DdSale> selectDdSaleList(DdSale ddSale) { public List<DdSale> selectDdSaleList(DdSale ddSale) {
return ddSaleMapper.selectDdSaleList(ddSale); return ddSaleMapper.selectDdSaleList(ddSale);
} }

View File

@@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if> <if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
${params.dataScope}
</where>ORDER BY g.group_id <!-- 确保正确排序 --> </where>ORDER BY g.group_id <!-- 确保正确排序 -->
</select> </select>
@@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf
FROM bas_sheep_group g FROM bas_sheep_group g
WHERE g.status = '0' WHERE g.status = '0'
${params.dataScope}
HAVING is_leaf = 1 HAVING is_leaf = 1
</select> </select>
@@ -87,6 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if> <if test="parentId != null">#{parentId},</if>
@@ -97,6 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -251,6 +251,8 @@
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="isDelete != null">is_delete,</if> <if test="isDelete != null">is_delete,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="manageTags != null">#{manageTags},</if> <if test="manageTags != null">#{manageTags},</if>
@@ -292,6 +294,8 @@
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="isDelete != null">#{isDelete},</if> <if test="isDelete != null">#{isDelete},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -62,6 +62,7 @@
<where> <where>
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if> <if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if> <if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
${params.dataScope}
</where> </where>
-- 按羊舍维度分组(牧场+羊舍类型+羊舍编号 唯一标识一个羊舍) -- 按羊舍维度分组(牧场+羊舍类型+羊舍编号 唯一标识一个羊舍)
GROUP BY ds.ranch_id, ds.sheepfold_type_id, ds.sheepfold_no GROUP BY ds.ranch_id, ds.sheepfold_type_id, ds.sheepfold_no
@@ -92,6 +93,7 @@
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if> <if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if> <if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
<if test="sheepfoldNo != null and sheepfoldNo != '' ">and ds.sheepfold_no = #{sheepfoldNo}</if> <if test="sheepfoldNo != null and sheepfoldNo != '' ">and ds.sheepfold_no = #{sheepfoldNo}</if>
${params.dataScope}
</where> </where>
GROUP BY ds.id,ds.ranch_id,ds.sheepfold_name,ds.sheepfold_type_id,ds.sheepfold_no,ds.row_no,ds.columns,ds.comment GROUP BY ds.id,ds.ranch_id,ds.sheepfold_name,ds.sheepfold_type_id,ds.sheepfold_no,ds.row_no,ds.columns,ds.comment
ORDER BY SUBSTRING_INDEX(ds.row_no, '-', 1), CAST(ds.columns AS UNSIGNED) ORDER BY SUBSTRING_INDEX(ds.row_no, '-', 1), CAST(ds.columns AS UNSIGNED)
@@ -112,6 +114,8 @@
<if test="rowNo != null">row_no,</if> <if test="rowNo != null">row_no,</if>
<if test="columns != null">columns,</if> <if test="columns != null">columns,</if>
<if test="comment != null">comment,</if> <if test="comment != null">comment,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ranchId != null">#{ranchId},</if> <if test="ranchId != null">#{ranchId},</if>
@@ -121,6 +125,8 @@
<if test="rowNo != null">#{rowNo},</if> <if test="rowNo != null">#{rowNo},</if>
<if test="columns != null">#{columns},</if> <if test="columns != null">#{columns},</if>
<if test="comment != null">#{comment},</if> <if test="comment != null">#{comment},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -90,6 +90,7 @@
<if test="gender != null "> and gender = #{gender}</if> <if test="gender != null "> and gender = #{gender}</if>
<if test="statusId != null "> and status_id = #{statusId}</if> <if test="statusId != null "> and status_id = #{statusId}</if>
<if test="breed != null and breed != ''"> and breed = #{breed}</if> <if test="breed != null and breed != ''"> and breed = #{breed}</if>
${params.dataScope}
</where> </where>
ORDER BY id ASC ORDER BY id ASC
</select> </select>
@@ -116,36 +117,49 @@
</select> </select>
<select id="countInGroup" resultType="java.lang.Long"> <select id="countInGroup" resultType="java.lang.Long">
SELECT COUNT(*) FROM sheep_file WHERE status_id = 1 AND (is_delete = 0 OR is_delete IS NULL) SELECT COUNT(*)
FROM sheep_file sf
WHERE sf.status_id = 1
AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
${params.dataScope}
</select> </select>
<select id="countBySheepType" resultType="java.util.Map"> <select id="countBySheepType" resultType="java.util.Map">
SELECT name AS name, COUNT(*) AS value SELECT sf.name AS name, COUNT(*) AS value
FROM sheep_file FROM sheep_file sf
WHERE status_id = 1 AND (is_delete = 0 OR is_delete IS NULL) WHERE sf.status_id = 1
GROUP BY name AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
${params.dataScope}
GROUP BY sf.name
</select> </select>
<select id="countByBreedStatus" resultType="java.util.Map"> <select id="countByBreedStatus" resultType="java.util.Map">
SELECT breed AS name, COUNT(*) AS value SELECT sf.breed AS name, COUNT(*) AS value
FROM sheep_file FROM sheep_file sf
WHERE status_id = 1 AND (is_delete = 0 OR is_delete IS NULL) WHERE sf.status_id = 1
GROUP BY breed AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
${params.dataScope}
GROUP BY sf.breed
</select> </select>
<select id="countByVariety" resultType="java.util.Map"> <select id="countByVariety" resultType="java.util.Map">
SELECT variety AS name, COUNT(*) AS value SELECT sf.variety AS name, COUNT(*) AS value
FROM sheep_file FROM sheep_file sf
WHERE status_id = 1 AND (is_delete = 0 OR is_delete IS NULL) WHERE sf.status_id = 1
GROUP BY variety AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
${params.dataScope}
GROUP BY sf.variety
</select> </select>
<select id="countParityOfLactation" resultType="java.util.Map"> <select id="countParityOfLactation" resultType="java.util.Map">
SELECT parity AS name, COUNT(*) AS value SELECT sf.parity AS name, COUNT(*) AS value
FROM sheep_file FROM sheep_file sf
WHERE status_id = 1 AND name = '泌乳羊' AND (is_delete = 0 OR is_delete IS NULL) WHERE sf.status_id = 1
GROUP BY parity AND sf.name = '泌乳羊'
ORDER BY parity AND (sf.is_delete = 0 OR sf.is_delete IS NULL)
${params.dataScope}
GROUP BY sf.parity
ORDER BY sf.parity
</select> </select>
<select id="selectFieldValues" parameterType="String" resultType="String"> <select id="selectFieldValues" parameterType="String" resultType="String">
@@ -268,6 +282,7 @@
</if> </if>
</foreach> </foreach>
</if> </if>
${params.dataScope}
</where> </where>
ORDER BY id ASC ORDER BY id ASC
</select> </select>

View File

@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectDdSaleVo"> <sql id="selectDdSaleVo">
select id, sale_date, cust_name, cust_phone, cust_addr, salesper, quaran_no, appr_no, price, tech, remark, create_by, create_time from dd_sl select id, sale_date, cust_name, cust_phone, cust_addr, salesper, quaran_no, appr_no, price, tech, remark, create_by, create_time from dd_sl dd_sl_alias
</sql> </sql>
<select id="selectDdSaleList" parameterType="DdSale" resultMap="DdSaleResult"> <select id="selectDdSaleList" parameterType="DdSale" resultMap="DdSaleResult">
@@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="apprNo != null and apprNo != ''"> and appr_no = #{apprNo}</if> <if test="apprNo != null and apprNo != ''"> and appr_no = #{apprNo}</if>
<if test="price != null "> and price = #{price}</if> <if test="price != null "> and price = #{price}</if>
<if test="tech != null and tech != ''"> and tech = #{tech}</if> <if test="tech != null and tech != ''"> and tech = #{tech}</if>
${params.dataScope}
</where> </where>
</select> </select>
@@ -83,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="saleDate != null">#{saleDate},</if> <if test="saleDate != null">#{saleDate},</if>
@@ -97,6 +100,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>