销售记录bug修改

This commit is contained in:
ll
2026-02-10 13:46:27 +08:00
parent b4d3943e6a
commit 38dc069ca1
6 changed files with 334 additions and 126 deletions

View File

@@ -1,6 +1,7 @@
package com.zhyc.module.sale.controller; package com.zhyc.module.sale.controller;
import java.util.List; import java.util.List;
import java.util.Date;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
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;
@@ -65,7 +66,7 @@ public class SxSheepSaleController extends BaseController {
public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult getInfo(@PathVariable("id") Long id) {
SxSheepSale sxSheepSale = sxSheepSaleService.selectSxSheepSaleById(id); SxSheepSale sxSheepSale = sxSheepSaleService.selectSxSheepSaleById(id);
// 将数据库中的逗号分隔的耳号字符串转换为列表 // 将数据库中的逗号分隔的耳号字符串转换为列表
if (sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) { if (sxSheepSale != null && sxSheepSale.getBsManageTags() != null && !sxSheepSale.getBsManageTags().isEmpty()) {
sxSheepSale.setBsManageTagsList(java.util.Arrays.asList(sxSheepSale.getBsManageTags().split(","))); sxSheepSale.setBsManageTagsList(java.util.Arrays.asList(sxSheepSale.getBsManageTags().split(",")));
} }
return success(sxSheepSale); return success(sxSheepSale);
@@ -81,6 +82,11 @@ public class SxSheepSaleController extends BaseController {
// 【新增】自动填充当前登录用户的 userId 和 deptId // 【新增】自动填充当前登录用户的 userId 和 deptId
sxSheepSale.setUserId(getUserId()); sxSheepSale.setUserId(getUserId());
sxSheepSale.setDeptId(getDeptId()); sxSheepSale.setDeptId(getDeptId());
// 【新增】自动填充创建人和创建时间,以便列表查询时显示
sxSheepSale.setCreatedBy(getUserId());
sxSheepSale.setCreatedAt(new Date());
return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale)); return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale));
} }
@@ -117,4 +123,26 @@ public class SxSheepSaleController extends BaseController {
} }
return AjaxResult.success(sheepInfo); return AjaxResult.success(sheepInfo);
} }
/**
* 根据羊舍ID获取羊只耳号列表
*/
@GetMapping("/listSheepBySheepfoldId")
public AjaxResult listSheepBySheepfoldId(@RequestParam Long sheepfoldId) {
List<String> list = sxSheepSaleService.selectSheepTagsBySheepfoldId(sheepfoldId);
return AjaxResult.success(list);
}
/**
* 【新增】搜索耳号(模糊查询)
*/
@GetMapping("/searchEarNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
List<String> earNumbers = sxSheepSaleService.searchEarNumbers(query);
return success(earNumbers);
} catch (Exception e) {
return error("搜索耳号失败:" + e.getMessage());
}
}
} }

View File

@@ -25,46 +25,10 @@ public class SxSheepSale extends BaseEntity {
@Excel(name = "耳号") @Excel(name = "耳号")
private String bsManageTags; private String bsManageTags;
/** 羊舍ID当时销售的羊舍 */
@Excel(name = "羊舍ID", readConverterExp = "当=时销售的羊舍")
private Long sheepfoldId;
/** 品种快照 */ /** 品种快照 */
@Excel(name = "品种快照") @Excel(name = "品种")
private String variety; private String variety;
/** 羊只类别快照 */
@Excel(name = "羊只类别快照")
private String sheepName;
/** 性别快照 */
@Excel(name = "性别快照")
private String gender;
/** 月龄快照 */
@Excel(name = "月龄快照")
private Long monthAge;
/** 胎次快照 */
@Excel(name = "胎次快照")
private Long parity;
/** 繁育状态快照 */
@Excel(name = "繁育状态快照")
private String breed;
/** 产后天数快照 */
@Excel(name = "产后天数快照")
private Long postLambingDay;
/** 泌乳天数快照 */
@Excel(name = "泌乳天数快照")
private Long lactationDay;
/** 怀孕天数快照 */
@Excel(name = "怀孕天数快照")
private Long lambingDay;
/** 事件类型 */ /** 事件类型 */
@Excel(name = "事件类型") @Excel(name = "事件类型")
private String eventType; private String eventType;
@@ -74,6 +38,26 @@ public class SxSheepSale extends BaseEntity {
@Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date saleDate; private Date saleDate;
/** 羊只类别快照 */
@Excel(name = "羊只类别")
private String sheepName;
/** 性别快照 */
@Excel(name = "性别")
private String gender;
/** 月龄快照 */
@Excel(name = "月龄")
private Long monthAge;
/** 胎次快照 */
@Excel(name = "胎次")
private Long parity;
/** 【新增】当前重量(档案关联生成) */
@Excel(name = "当前重量(kg)")
private BigDecimal currentWeight;
/** 计价方式 */ /** 计价方式 */
@Excel(name = "计价方式") @Excel(name = "计价方式")
private String pricingMethod; private String pricingMethod;
@@ -82,45 +66,37 @@ public class SxSheepSale extends BaseEntity {
@Excel(name = "单价") @Excel(name = "单价")
private BigDecimal unitPrice; private BigDecimal unitPrice;
/** 总价(自动计算) */ /** 重量(单只羊重量:单只时为总体重,多只时为平均重) - 对应数据库 avg_weight */
@Excel(name = "总价", readConverterExp = "自=动计算") @Excel(name = "重量(kg)")
private BigDecimal totalPrice;
/** 总体重(按体重时输入) */
@Excel(name = "总体重", readConverterExp = "按=体重时输入")
private BigDecimal totalWeight;
/** 平均体重(自动) */
@Excel(name = "平均体重", readConverterExp = "自=动")
private BigDecimal avgWeight; private BigDecimal avgWeight;
/** 平均单只价格(自动 */ /** 单只价格(单只羊销售时填的总价或计算的总价;多只羊销售时计算出每只羊的平均价格 */
@Excel(name = "平均单只价格", readConverterExp = "自=动") @Excel(name = "单只价格(元)")
private BigDecimal avgPricePerSheep; private BigDecimal avgPricePerSheep;
/** 销售类别dict_type = sale_type */ /** 销售类别dict_type = sale_type */
@Excel(name = "销售类别", readConverterExp = "d=ict_type,==,s=ale_type") @Excel(name = "销售类别", dictType = "sale_type")
private String saleType; private String saleType;
/** 疾病类型dict_type = disea_type */ /** 【非数据库字段】客户名称 */
@Excel(name = "疾病类型", readConverterExp = "d=ict_type,==,d=isea_type") @Excel(name = "客户名称")
private String diseaseType; private String customerName;
/** 次要原因 */ /** 【非数据库字段】客户电话 */
@Excel(name = "次要原因") @Excel(name = "客户电话")
private String secondaryReason; private String customerPhone;
/** 班组dict_type = group */ /** 【新增】【非数据库字段】所在地区 */
@Excel(name = "班组", readConverterExp = "d=ict_type,==,g=roup") @Excel(name = "所在地区")
private String groupCode; private String customerArea;
/** 客户IDsx_customer.id */ /** 【非数据库字段】客户地址 */
@Excel(name = "客户ID", readConverterExp = "s=x_customer.id") @Excel(name = "详细地址")
private Long customerId; private String customerAddress;
/** 销售人员IDsys_user.id */ /** 【非数据库字段】销售人员姓名 */
@Excel(name = "销售人员ID", readConverterExp = "s=ys_user.id") @Excel(name = "销售人员")
private Long salesPersonId; private String salesPersonName;
/** 检疫证号 */ /** 检疫证号 */
@Excel(name = "检疫证号") @Excel(name = "检疫证号")
@@ -130,48 +106,91 @@ public class SxSheepSale extends BaseEntity {
@Excel(name = "审批编号") @Excel(name = "审批编号")
private String approvalNo; private String approvalNo;
/** 技术员IDsys_user.id */ /** 疾病类型dict_type = disease_type */
@Excel(name = "技术员ID", readConverterExp = "s=ys_user.id") @Excel(name = "疾病类型", dictType = "disease_type")
private Long technicianId; private String diseaseType;
/** 处理人IDsys_user.id */ /** 次要原因 */
@Excel(name = "处理人ID", readConverterExp = "s=ys_user.id") @Excel(name = "次要原因")
private Long handlerId; private String secondaryReason;
/** 创建人IDsys_user.id */ /** 【非数据库字段】羊舍名称 */
@Excel(name = "创建人ID", readConverterExp = "s=ys_user.id") @Excel(name = "羊舍")
private Long createdBy; private String sheepfoldName;
/** 班组dict_type = group */
@Excel(name = "班组", dictType = "group")
private String groupCode;
/** 繁育状态快照 */
@Excel(name = "繁育状态")
private String breed;
/** 产后天数快照 */
@Excel(name = "销售时产后天数")
private Long postLambingDay;
/** 泌乳天数快照 */
@Excel(name = "销售时泌乳天数")
private Long lactationDay;
/** 怀孕天数快照 */
@Excel(name = "销售时怀孕天数")
private Long lambingDay;
/** 【非数据库字段】技术员姓名 */
@Excel(name = "技术员")
private String technicianName;
/** 【非数据库字段】处理人姓名 */
@Excel(name = "处理人")
private String handlerName;
/** 【非数据库字段】创建人姓名 */
@Excel(name = "创建人")
private String createdByName;
/** 创建时间 */ /** 创建时间 */
@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 createdAt; private Date createdAt;
// --- 以下字段在导出中不显示,但在业务中需要 ---
/** 总价(自动计算) */
private BigDecimal totalPrice;
/** 总体重(按体重时输入) */
private BigDecimal totalWeight;
/** 羊舍ID当时销售的羊舍 */
private Long sheepfoldId;
/** 客户IDsx_customer.id */
private Long customerId;
/** 销售人员IDsys_user.id */
private Long salesPersonId;
/** 技术员IDsys_user.id */
private Long technicianId;
/** 处理人IDsys_user.id */
private Long handlerId;
/** 创建人IDsys_user.id */
private Long createdBy;
/** 用户ID */ /** 用户ID */
private Long userId; private Long userId;
/** 部门ID */ /** 部门ID */
private Long deptId; private Long deptId;
// 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号 // --- 非数据库辅助字段 ---
private List<String> bsManageTagsList;
// 【新增】非数据库字段:客户名称(从客户表查询) /** 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号 */
private String customerName; private List<String> bsManageTagsList;
// 【新增】非数据库字段:客户电话
private String customerPhone;
// 【新增】非数据库字段:客户地址
private String customerAddress;
// 【新增】非数据库字段:销售人员姓名
private String salesPersonName;
// 【新增】非数据库字段:技术员姓名
private String technicianName;
// 【新增】非数据库字段:处理人姓名
private String handlerName;
// 【新增】非数据库字段:创建人姓名
private String createdByName;
// 【新增】非数据库字段:羊舍名称
private String sheepfoldName;
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
@@ -445,7 +464,6 @@ public class SxSheepSale extends BaseEntity {
this.deptId = deptId; this.deptId = deptId;
} }
// 【新增】getter 和 setter 方法
public List<String> getBsManageTagsList() { public List<String> getBsManageTagsList() {
return bsManageTagsList; return bsManageTagsList;
} }
@@ -518,6 +536,22 @@ public class SxSheepSale extends BaseEntity {
this.sheepfoldName = sheepfoldName; this.sheepfoldName = sheepfoldName;
} }
public BigDecimal getCurrentWeight() {
return currentWeight;
}
public void setCurrentWeight(BigDecimal currentWeight) {
this.currentWeight = currentWeight;
}
public String getCustomerArea() {
return customerArea;
}
public void setCustomerArea(String customerArea) {
this.customerArea = customerArea;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -559,11 +593,13 @@ public class SxSheepSale extends BaseEntity {
.append("customerName", getCustomerName()) .append("customerName", getCustomerName())
.append("customerPhone", getCustomerPhone()) .append("customerPhone", getCustomerPhone())
.append("customerAddress", getCustomerAddress()) .append("customerAddress", getCustomerAddress())
.append("customerArea", getCustomerArea())
.append("salesPersonName", getSalesPersonName()) .append("salesPersonName", getSalesPersonName())
.append("technicianName", getTechnicianName()) .append("technicianName", getTechnicianName())
.append("handlerName", getHandlerName()) .append("handlerName", getHandlerName())
.append("createdByName", getCreatedByName()) .append("createdByName", getCreatedByName())
.append("sheepfoldName", getSheepfoldName()) .append("sheepfoldName", getSheepfoldName())
.append("currentWeight", getCurrentWeight())
.toString(); .toString();
} }
} }

View File

@@ -65,4 +65,19 @@ public interface SxSheepSaleMapper {
* @return 羊只信息 (只包含视图中的字段) * @return 羊只信息 (只包含视图中的字段)
*/ */
public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags); public SxSheepSale selectSheepInfoByTag(@Param("bsManageTags") String bsManageTags);
/**
* 根据羊舍ID查询存栏羊只耳号列表
* @param sheepfoldId 羊舍ID
* @return 耳号列表
*/
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId);
/**
* 【新增】模糊查询羊只耳号列表(用于前端搜索补全)
* @param query 查询关键字
* @return 耳号列表
*/
public List<String> searchEarNumbers(@Param("query") String query);
} }

View File

@@ -59,9 +59,21 @@ public interface ISxSheepSaleService {
public int deleteSxSheepSaleById(Long id); public int deleteSxSheepSaleById(Long id);
/** /**
* 【新增】根据耳号查询羊只信息 * 根据耳号查询羊只信息
* @param bsManageTags 耳号 * @param bsManageTags 耳号
* @return 羊只信息 * @return 羊只信息
*/ */
public SxSheepSale selectSheepInfoByTag(String bsManageTags); public SxSheepSale selectSheepInfoByTag(String bsManageTags);
/**
* 根据羊舍ID查询存栏羊只耳号列表
*/
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId);
/**
* 【新增】模糊查询羊只耳号列表
* @param query 查询关键字
* @return 耳号列表
*/
public List<String> searchEarNumbers(String query);
} }

View File

@@ -5,7 +5,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.common.annotation.DataScope; // 【新增】引入数据权限注解 import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.sale.mapper.SxSheepSaleMapper; import com.zhyc.module.sale.mapper.SxSheepSaleMapper;
import com.zhyc.module.sale.domain.SxSheepSale; import com.zhyc.module.sale.domain.SxSheepSale;
import com.zhyc.module.sale.service.ISxSheepSaleService; import com.zhyc.module.sale.service.ISxSheepSaleService;
@@ -34,7 +34,6 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
/** /**
* 查询羊只销售记录列表 * 查询羊只销售记录列表
* 【新增】添加数据权限过滤注解
* deptAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s * deptAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s
* userAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s * userAlias = "s": 对应 Mapper.xml 中表 sx_sheep_sale 的别名 s
* *
@@ -55,10 +54,10 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
*/ */
@Override @Override
public int insertSxSheepSale(SxSheepSale sxSheepSale) { public int insertSxSheepSale(SxSheepSale sxSheepSale) {
// 1. 业务验证 (例如:销售日期不能为空,淘汰销售必须填写疾病类型等) // 1. 业务验证 (必填项校验、级联校验)
validateSalesFields(sxSheepSale); validateSalesFields(sxSheepSale);
// 2. 自动计算逻辑 // 2. 自动计算逻辑 (价格、体重)
calculateSalesFields(sxSheepSale); calculateSalesFields(sxSheepSale);
// 3. 设置默认事件类型 // 3. 设置默认事件类型
@@ -121,21 +120,34 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
} }
/** /**
* 【新增】根据耳号查询羊只信息 * 根据耳号查询羊只信息
*/ */
@Override @Override
public SxSheepSale selectSheepInfoByTag(String bsManageTags) { public SxSheepSale selectSheepInfoByTag(String bsManageTags) {
return sxSheepSaleMapper.selectSheepInfoByTag(bsManageTags); return sxSheepSaleMapper.selectSheepInfoByTag(bsManageTags);
} }
@Override
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId) {
return sxSheepSaleMapper.selectSheepTagsBySheepfoldId(sheepfoldId);
}
/** /**
* 【新增】自动计算总价、平均体重、平均单只价格 * 【新增】实现模糊查询耳号
*/
@Override
public List<String> searchEarNumbers(String query) {
return sxSheepSaleMapper.searchEarNumbers(query);
}
/**
* 自动计算总价、平均体重、平均单只价格
*/ */
private void calculateSalesFields(SxSheepSale sxSheepSale) { private void calculateSalesFields(SxSheepSale sxSheepSale) {
String pricingMethod = sxSheepSale.getPricingMethod(); String pricingMethod = sxSheepSale.getPricingMethod();
BigDecimal unitPrice = sxSheepSale.getUnitPrice(); BigDecimal unitPrice = sxSheepSale.getUnitPrice();
// 获取羊只数量 // 获取羊只数量默认为1防止除零
int sheepCount = 1; int sheepCount = 1;
if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) { if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
sheepCount = sxSheepSale.getBsManageTagsList().size(); sheepCount = sxSheepSale.getBsManageTagsList().size();
@@ -145,6 +157,7 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
} }
if ("按个体".equals(pricingMethod)) { if ("按个体".equals(pricingMethod)) {
// 按个体计算逻辑
// 总价 = 单价 * 数量 // 总价 = 单价 * 数量
if (unitPrice != null) { if (unitPrice != null) {
sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount))); sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount)));
@@ -152,43 +165,60 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
// 平均单只价格就是单价 // 平均单只价格就是单价
sxSheepSale.setAvgPricePerSheep(unitPrice); sxSheepSale.setAvgPricePerSheep(unitPrice);
// 按个体时,无需计算平均体重,清空相关字段避免混淆(可视需求决定是否保留)
sxSheepSale.setAvgWeight(null);
} else if ("按体重".equals(pricingMethod)) { } else if ("按体重".equals(pricingMethod)) {
// 按体重计算逻辑
BigDecimal totalWeight = sxSheepSale.getTotalWeight(); BigDecimal totalWeight = sxSheepSale.getTotalWeight();
// 总价 = 单价 * 总重量 // 总价 = 单价 * 总重量
if (unitPrice != null && totalWeight != null) { if (unitPrice != null && totalWeight != null) {
sxSheepSale.setTotalPrice(unitPrice.multiply(totalWeight)); sxSheepSale.setTotalPrice(unitPrice.multiply(totalWeight));
} }
// 平均体重 = 总重量 / 数量 // 平均体重 = 总重量 / 数量
if (totalWeight != null && sheepCount > 0) { if (totalWeight != null && sheepCount > 0) {
sxSheepSale.setAvgWeight(totalWeight.divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP)); sxSheepSale.setAvgWeight(totalWeight.divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
} }
// 平均单只价格 = 总价 / 数量 // 平均单只价格 = 总价 / 数量
if (sxSheepSale.getTotalPrice() != null && sheepCount > 0) { if (sxSheepSale.getTotalPrice() != null && sheepCount > 0) {
sxSheepSale.setAvgPricePerSheep(sxSheepSale.getTotalPrice().divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP)); sxSheepSale.setAvgPricePerSheep(sxSheepSale.getTotalPrice().divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
} }
} }
// 可以添加其他计价方式的逻辑
} }
/** /**
* 【新增】业务字段验证 * 业务字段验证
*/ */
private void validateSalesFields(SxSheepSale sxSheepSale) { private void validateSalesFields(SxSheepSale sxSheepSale) {
// 验证销售日期不能为空 // 1. 基础必填校验
if (sxSheepSale.getSaleDate() == null) { if (sxSheepSale.getSaleDate() == null) {
throw new RuntimeException("销售日期不能为空!"); throw new RuntimeException("销售日期不能为空!");
} }
if (sxSheepSale.getTechnicianId() == null) {
throw new RuntimeException("技术员不能为空!");
}
if (sxSheepSale.getHandlerId() == null) {
throw new RuntimeException("处理人不能为空!");
}
if (sxSheepSale.getGroupCode() == null || sxSheepSale.getGroupCode().trim().isEmpty()) {
throw new RuntimeException("班组不能为空!");
}
if (sxSheepSale.getPricingMethod() == null || sxSheepSale.getPricingMethod().trim().isEmpty()) {
throw new RuntimeException("计价方式不能为空!");
}
// 2. 级联校验
String saleType = sxSheepSale.getSaleType(); String saleType = sxSheepSale.getSaleType();
// 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型和班组不能为空 // 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型不能为空
if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) { if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) {
if (sxSheepSale.getDiseaseType() == null) { if (sxSheepSale.getDiseaseType() == null || sxSheepSale.getDiseaseType().trim().isEmpty()) {
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!"); throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!");
} }
if (sxSheepSale.getGroupCode() == null) {
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择班组!");
}
} }
// 如果疾病类型是"病残羊",则次要原因不能为空 // 如果疾病类型是"病残羊",则次要原因不能为空
if ("病残羊".equals(sxSheepSale.getDiseaseType())) { if ("病残羊".equals(sxSheepSale.getDiseaseType())) {
if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) { if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) {

View File

@@ -38,6 +38,17 @@
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="deptId" column="dept_id" /> <result property="deptId" column="dept_id" />
<result property="customerName" column="customer_name" />
<result property="customerPhone" column="customer_phone" />
<result property="customerAddress" column="customer_address" />
<result property="customerArea" column="customer_area" />
<result property="salesPersonName" column="sales_person_name" />
<result property="technicianName" column="technician_name" />
<result property="handlerName" column="handler_name" />
<result property="createdByName" column="created_by_name" />
<result property="sheepfoldName" column="sheepfold_name" />
<result property="currentWeight" column="current_weight" />
</resultMap> </resultMap>
<sql id="selectSxSheepSaleVo"> <sql id="selectSxSheepSaleVo">
@@ -45,6 +56,85 @@
from sx_sheep_sale s from sx_sheep_sale s
</sql> </sql>
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult">
SELECT
s.*,
c.name AS customer_name,
c.phone AS customer_phone,
c.address AS customer_address,
CONCAT(IFNULL(c.province,''), IFNULL(c.city,''), IFNULL(c.district,'')) AS customer_area,
u_sale.nick_name AS sales_person_name,
u_tech.nick_name AS technician_name,
u_hand.nick_name AS handler_name,
u_create.nick_name AS created_by_name,
sf.sheepfold_name AS sheepfold_name
FROM sx_sheep_sale s
LEFT JOIN sx_customer c ON s.customer_id = c.id
LEFT JOIN sys_user u_sale ON s.sales_person_id = u_sale.user_id
LEFT JOIN sys_user u_tech ON s.technician_id = u_tech.user_id
LEFT JOIN sys_user u_hand ON s.handler_id = u_hand.user_id
LEFT JOIN sys_user u_create ON s.created_by = u_create.user_id
LEFT JOIN da_sheepfold sf ON s.sheepfold_id = sf.id
<where>
<if test="bsManageTagsList != null and bsManageTagsList.size() > 0">
AND s.bs_manage_tags IN
<foreach collection="bsManageTagsList" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
</if>
<if test="(bsManageTagsList == null or bsManageTagsList.size() == 0) and bsManageTags != null and bsManageTags != ''">
AND s.bs_manage_tags LIKE CONCAT('%', #{bsManageTags}, '%')
</if>
<if test="sheepfoldId != null "> AND s.sheepfold_id = #{sheepfoldId}</if>
<if test="variety != null and variety != ''"> AND s.variety = #{variety}</if>
<if test="sheepName != null and sheepName != ''"> AND s.sheep_name = #{sheepName}</if>
<if test="gender != null and gender != ''"> AND s.gender = #{gender}</if>
<if test="breed != null and breed != ''"> AND s.breed = #{breed}</if>
<if test="saleDate != null"> AND s.sale_date = #{saleDate}</if>
<if test="saleType != null and saleType != ''"> AND s.sale_type = #{saleType}</if>
<if test="pricingMethod != null and pricingMethod != ''"> AND s.pricing_method = #{pricingMethod}</if>
<if test="groupCode != null and groupCode != ''"> AND s.group_code = #{groupCode}</if>
<if test="approvalNo != null and approvalNo != ''">
AND s.approval_no LIKE CONCAT('%', #{approvalNo}, '%')
</if>
<if test="customerName != null and customerName != ''"> AND c.name LIKE CONCAT('%', #{customerName}, '%')</if>
<if test="salesPersonId != null"> AND s.sales_person_id = #{salesPersonId}</if>
<if test="customerArea != null and customerArea != ''">
AND (c.province LIKE CONCAT('%', #{customerArea}, '%')
OR c.city LIKE CONCAT('%', #{customerArea}, '%')
OR c.district LIKE CONCAT('%', #{customerArea}, '%'))
</if>
${params.dataScope}
</where>
ORDER BY s.sale_date DESC, s.id DESC
</select>
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult">
SELECT
s.*,
c.name AS customer_name,
c.phone AS customer_phone,
c.address AS customer_address,
CONCAT(IFNULL(c.province,''), IFNULL(c.city,''), IFNULL(c.district,'')) AS customer_area,
u_sale.nick_name AS sales_person_name,
u_tech.nick_name AS technician_name,
u_hand.nick_name AS handler_name,
u_create.nick_name AS created_by_name,
sf.sheepfold_name AS sheepfold_name
FROM sx_sheep_sale s
LEFT JOIN sx_customer c ON s.customer_id = c.id
LEFT JOIN sys_user u_sale ON s.sales_person_id = u_sale.user_id
LEFT JOIN sys_user u_tech ON s.technician_id = u_tech.user_id
LEFT JOIN sys_user u_hand ON s.handler_id = u_hand.user_id
LEFT JOIN sys_user u_create ON s.created_by = u_create.user_id
LEFT JOIN da_sheepfold sf ON s.sheepfold_id = sf.id
WHERE s.id = #{id}
</select>
<sql id="selectSheepFileVo"> <sql id="selectSheepFileVo">
select select
bs_manage_tags, bs_manage_tags,
@@ -57,7 +147,8 @@
post_lambing_day, post_lambing_day,
lactation_day, lactation_day,
lambing_day, lambing_day,
sheepfold_id sheepfold_id,
current_weight
from sheep_file from sheep_file
</sql> </sql>
@@ -66,22 +157,18 @@
where bs_manage_tags = #{bsManageTags} where bs_manage_tags = #{bsManageTags}
</select> </select>
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult"> <select id="selectSheepTagsBySheepfoldId" parameterType="Long" resultType="String">
<include refid="selectSxSheepSaleVo"/> SELECT bs_manage_tags
<where> FROM sheep_file
<if test="bsManageTags != null and bsManageTags != ''"> and s.bs_manage_tags = #{bsManageTags}</if> WHERE sheepfold_id = #{sheepfoldId}
<if test="sheepfoldId != null "> and s.sheepfold_id = #{sheepfoldId}</if>
<if test="variety != null and variety != ''"> and s.variety = #{variety}</if>
<if test="sheepName != null and sheepName != ''"> and s.sheep_name = #{sheepName}</if>
<if test="saleDate != null"> and s.sale_date = #{saleDate}</if>
<if test="saleType != null and saleType != ''"> and s.sale_type = #{saleType}</if>
${params.dataScope}
</where>
</select> </select>
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult"> <select id="searchEarNumbers" resultType="java.lang.String">
<include refid="selectSxSheepSaleVo"/> SELECT DISTINCT bs_manage_tags
where s.id = #{id} FROM sheep_file
WHERE bs_manage_tags LIKE CONCAT(#{query}, '%')
ORDER BY bs_manage_tags
LIMIT 50
</select> </select>
<insert id="insertSxSheepSale" parameterType="SxSheepSale" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSxSheepSale" parameterType="SxSheepSale" useGeneratedKeys="true" keyProperty="id">