销售记录bug修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.sale.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -65,7 +66,7 @@ public class SxSheepSaleController extends BaseController {
|
||||
public AjaxResult getInfo(@PathVariable("id") Long 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(",")));
|
||||
}
|
||||
return success(sxSheepSale);
|
||||
@@ -81,6 +82,11 @@ public class SxSheepSaleController extends BaseController {
|
||||
// 【新增】自动填充当前登录用户的 userId 和 deptId
|
||||
sxSheepSale.setUserId(getUserId());
|
||||
sxSheepSale.setDeptId(getDeptId());
|
||||
|
||||
// 【新增】自动填充创建人和创建时间,以便列表查询时显示
|
||||
sxSheepSale.setCreatedBy(getUserId());
|
||||
sxSheepSale.setCreatedAt(new Date());
|
||||
|
||||
return toAjax(sxSheepSaleService.insertSxSheepSale(sxSheepSale));
|
||||
}
|
||||
|
||||
@@ -117,4 +123,26 @@ public class SxSheepSaleController extends BaseController {
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,46 +25,10 @@ public class SxSheepSale extends BaseEntity {
|
||||
@Excel(name = "耳号")
|
||||
private String bsManageTags;
|
||||
|
||||
/** 羊舍ID(当时销售的羊舍) */
|
||||
@Excel(name = "羊舍ID", readConverterExp = "当=时销售的羊舍")
|
||||
private Long sheepfoldId;
|
||||
|
||||
/** 品种快照 */
|
||||
@Excel(name = "品种快照")
|
||||
@Excel(name = "品种")
|
||||
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 = "事件类型")
|
||||
private String eventType;
|
||||
@@ -74,6 +38,26 @@ public class SxSheepSale extends BaseEntity {
|
||||
@Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
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 = "计价方式")
|
||||
private String pricingMethod;
|
||||
@@ -82,45 +66,37 @@ public class SxSheepSale extends BaseEntity {
|
||||
@Excel(name = "单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/** 总价(自动计算) */
|
||||
@Excel(name = "总价", readConverterExp = "自=动计算")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/** 总体重(按体重时输入) */
|
||||
@Excel(name = "总体重", readConverterExp = "按=体重时输入")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/** 平均体重(自动) */
|
||||
@Excel(name = "平均体重", readConverterExp = "自=动")
|
||||
/** 重量(单只羊重量:单只时为总体重,多只时为平均重) - 对应数据库 avg_weight */
|
||||
@Excel(name = "重量(kg)")
|
||||
private BigDecimal avgWeight;
|
||||
|
||||
/** 平均单只价格(自动) */
|
||||
@Excel(name = "平均单只价格", readConverterExp = "自=动")
|
||||
/** 单只羊价格(单只羊销售时填的总价或计算的总价;多只羊销售时计算出每只羊的平均价格) */
|
||||
@Excel(name = "单只羊价格(元)")
|
||||
private BigDecimal avgPricePerSheep;
|
||||
|
||||
/** 销售类别(dict_type = sale_type) */
|
||||
@Excel(name = "销售类别", readConverterExp = "d=ict_type,==,s=ale_type")
|
||||
@Excel(name = "销售类别", dictType = "sale_type")
|
||||
private String saleType;
|
||||
|
||||
/** 疾病类型(dict_type = disea_type) */
|
||||
@Excel(name = "疾病类型", readConverterExp = "d=ict_type,==,d=isea_type")
|
||||
private String diseaseType;
|
||||
/** 【非数据库字段】客户名称 */
|
||||
@Excel(name = "客户名称")
|
||||
private String customerName;
|
||||
|
||||
/** 次要原因 */
|
||||
@Excel(name = "次要原因")
|
||||
private String secondaryReason;
|
||||
/** 【非数据库字段】客户电话 */
|
||||
@Excel(name = "客户电话")
|
||||
private String customerPhone;
|
||||
|
||||
/** 班组(dict_type = group) */
|
||||
@Excel(name = "班组", readConverterExp = "d=ict_type,==,g=roup")
|
||||
private String groupCode;
|
||||
/** 【新增】【非数据库字段】所在地区 */
|
||||
@Excel(name = "所在地区")
|
||||
private String customerArea;
|
||||
|
||||
/** 客户ID(sx_customer.id) */
|
||||
@Excel(name = "客户ID", readConverterExp = "s=x_customer.id")
|
||||
private Long customerId;
|
||||
/** 【非数据库字段】客户地址 */
|
||||
@Excel(name = "详细地址")
|
||||
private String customerAddress;
|
||||
|
||||
/** 销售人员ID(sys_user.id) */
|
||||
@Excel(name = "销售人员ID", readConverterExp = "s=ys_user.id")
|
||||
private Long salesPersonId;
|
||||
/** 【非数据库字段】销售人员姓名 */
|
||||
@Excel(name = "销售人员")
|
||||
private String salesPersonName;
|
||||
|
||||
/** 检疫证号 */
|
||||
@Excel(name = "检疫证号")
|
||||
@@ -130,48 +106,91 @@ public class SxSheepSale extends BaseEntity {
|
||||
@Excel(name = "审批编号")
|
||||
private String approvalNo;
|
||||
|
||||
/** 技术员ID(sys_user.id) */
|
||||
@Excel(name = "技术员ID", readConverterExp = "s=ys_user.id")
|
||||
private Long technicianId;
|
||||
/** 疾病类型(dict_type = disease_type) */
|
||||
@Excel(name = "疾病类型", dictType = "disease_type")
|
||||
private String diseaseType;
|
||||
|
||||
/** 处理人ID(sys_user.id) */
|
||||
@Excel(name = "处理人ID", readConverterExp = "s=ys_user.id")
|
||||
private Long handlerId;
|
||||
/** 次要原因 */
|
||||
@Excel(name = "次要原因")
|
||||
private String secondaryReason;
|
||||
|
||||
/** 创建人ID(sys_user.id) */
|
||||
@Excel(name = "创建人ID", readConverterExp = "s=ys_user.id")
|
||||
private Long createdBy;
|
||||
/** 【非数据库字段】羊舍名称 */
|
||||
@Excel(name = "羊舍")
|
||||
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")
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@Excel(name = "创建日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date createdAt;
|
||||
|
||||
// --- 以下字段在导出中不显示,但在业务中需要 ---
|
||||
|
||||
/** 总价(自动计算) */
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
/** 总体重(按体重时输入) */
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/** 羊舍ID(当时销售的羊舍) */
|
||||
private Long sheepfoldId;
|
||||
|
||||
/** 客户ID(sx_customer.id) */
|
||||
private Long customerId;
|
||||
|
||||
/** 销售人员ID(sys_user.id) */
|
||||
private Long salesPersonId;
|
||||
|
||||
/** 技术员ID(sys_user.id) */
|
||||
private Long technicianId;
|
||||
|
||||
/** 处理人ID(sys_user.id) */
|
||||
private Long handlerId;
|
||||
|
||||
/** 创建人ID(sys_user.id) */
|
||||
private Long createdBy;
|
||||
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
// 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号
|
||||
private List<String> bsManageTagsList;
|
||||
// --- 非数据库辅助字段 ---
|
||||
|
||||
// 【新增】非数据库字段:客户名称(从客户表查询)
|
||||
private String customerName;
|
||||
// 【新增】非数据库字段:客户电话
|
||||
private String customerPhone;
|
||||
// 【新增】非数据库字段:客户地址
|
||||
private String customerAddress;
|
||||
// 【新增】非数据库字段:销售人员姓名
|
||||
private String salesPersonName;
|
||||
// 【新增】非数据库字段:技术员姓名
|
||||
private String technicianName;
|
||||
// 【新增】非数据库字段:处理人姓名
|
||||
private String handlerName;
|
||||
// 【新增】非数据库字段:创建人姓名
|
||||
private String createdByName;
|
||||
// 【新增】非数据库字段:羊舍名称
|
||||
private String sheepfoldName;
|
||||
/** 【新增】非数据库字段:用于前端展示和选择羊舍后传递多个耳号 */
|
||||
private List<String> bsManageTagsList;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
@@ -445,7 +464,6 @@ public class SxSheepSale extends BaseEntity {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
// 【新增】getter 和 setter 方法
|
||||
public List<String> getBsManageTagsList() {
|
||||
return bsManageTagsList;
|
||||
}
|
||||
@@ -518,6 +536,22 @@ public class SxSheepSale extends BaseEntity {
|
||||
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
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@@ -559,11 +593,13 @@ public class SxSheepSale extends BaseEntity {
|
||||
.append("customerName", getCustomerName())
|
||||
.append("customerPhone", getCustomerPhone())
|
||||
.append("customerAddress", getCustomerAddress())
|
||||
.append("customerArea", getCustomerArea())
|
||||
.append("salesPersonName", getSalesPersonName())
|
||||
.append("technicianName", getTechnicianName())
|
||||
.append("handlerName", getHandlerName())
|
||||
.append("createdByName", getCreatedByName())
|
||||
.append("sheepfoldName", getSheepfoldName())
|
||||
.append("currentWeight", getCurrentWeight())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -65,4 +65,19 @@ public interface SxSheepSaleMapper {
|
||||
* @return 羊只信息 (只包含视图中的字段)
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -59,9 +59,21 @@ public interface ISxSheepSaleService {
|
||||
public int deleteSxSheepSaleById(Long id);
|
||||
|
||||
/**
|
||||
* 【新增】根据耳号查询羊只信息
|
||||
* 根据耳号查询羊只信息
|
||||
* @param bsManageTags 耳号
|
||||
* @return 羊只信息
|
||||
*/
|
||||
public SxSheepSale selectSheepInfoByTag(String bsManageTags);
|
||||
|
||||
/**
|
||||
* 根据羊舍ID查询存栏羊只耳号列表
|
||||
*/
|
||||
public List<String> selectSheepTagsBySheepfoldId(Long sheepfoldId);
|
||||
|
||||
/**
|
||||
* 【新增】模糊查询羊只耳号列表
|
||||
* @param query 查询关键字
|
||||
* @return 耳号列表
|
||||
*/
|
||||
public List<String> searchEarNumbers(String query);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.domain.SxSheepSale;
|
||||
import com.zhyc.module.sale.service.ISxSheepSaleService;
|
||||
@@ -34,7 +34,6 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
|
||||
|
||||
/**
|
||||
* 查询羊只销售记录列表
|
||||
* 【新增】添加数据权限过滤注解
|
||||
* deptAlias = "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
|
||||
public int insertSxSheepSale(SxSheepSale sxSheepSale) {
|
||||
// 1. 业务验证 (例如:销售日期不能为空,淘汰销售必须填写疾病类型等)
|
||||
// 1. 业务验证 (必填项校验、级联校验)
|
||||
validateSalesFields(sxSheepSale);
|
||||
|
||||
// 2. 自动计算逻辑
|
||||
// 2. 自动计算逻辑 (价格、体重)
|
||||
calculateSalesFields(sxSheepSale);
|
||||
|
||||
// 3. 设置默认事件类型
|
||||
@@ -121,21 +120,34 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】根据耳号查询羊只信息
|
||||
* 根据耳号查询羊只信息
|
||||
*/
|
||||
@Override
|
||||
public SxSheepSale selectSheepInfoByTag(String 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) {
|
||||
String pricingMethod = sxSheepSale.getPricingMethod();
|
||||
BigDecimal unitPrice = sxSheepSale.getUnitPrice();
|
||||
|
||||
// 获取羊只数量
|
||||
// 获取羊只数量,默认为1防止除零
|
||||
int sheepCount = 1;
|
||||
if (sxSheepSale.getBsManageTagsList() != null && !sxSheepSale.getBsManageTagsList().isEmpty()) {
|
||||
sheepCount = sxSheepSale.getBsManageTagsList().size();
|
||||
@@ -145,6 +157,7 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
|
||||
}
|
||||
|
||||
if ("按个体".equals(pricingMethod)) {
|
||||
// 按个体计算逻辑
|
||||
// 总价 = 单价 * 数量
|
||||
if (unitPrice != null) {
|
||||
sxSheepSale.setTotalPrice(unitPrice.multiply(new BigDecimal(sheepCount)));
|
||||
@@ -152,43 +165,60 @@ public class SxSheepSaleServiceImpl implements ISxSheepSaleService {
|
||||
// 平均单只价格就是单价
|
||||
sxSheepSale.setAvgPricePerSheep(unitPrice);
|
||||
|
||||
// 按个体时,无需计算平均体重,清空相关字段避免混淆(可视需求决定是否保留)
|
||||
sxSheepSale.setAvgWeight(null);
|
||||
|
||||
} else if ("按体重".equals(pricingMethod)) {
|
||||
// 按体重计算逻辑
|
||||
BigDecimal totalWeight = sxSheepSale.getTotalWeight();
|
||||
|
||||
// 总价 = 单价 * 总重量
|
||||
if (unitPrice != null && totalWeight != null) {
|
||||
sxSheepSale.setTotalPrice(unitPrice.multiply(totalWeight));
|
||||
}
|
||||
|
||||
// 平均体重 = 总重量 / 数量
|
||||
if (totalWeight != null && sheepCount > 0) {
|
||||
sxSheepSale.setAvgWeight(totalWeight.divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
// 平均单只价格 = 总价 / 数量
|
||||
if (sxSheepSale.getTotalPrice() != null && sheepCount > 0) {
|
||||
sxSheepSale.setAvgPricePerSheep(sxSheepSale.getTotalPrice().divide(new BigDecimal(sheepCount), 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
// 可以添加其他计价方式的逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 【新增】业务字段验证
|
||||
* 业务字段验证
|
||||
*/
|
||||
private void validateSalesFields(SxSheepSale sxSheepSale) {
|
||||
// 验证销售日期不能为空
|
||||
// 1. 基础必填校验
|
||||
if (sxSheepSale.getSaleDate() == null) {
|
||||
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();
|
||||
// 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型和班组不能为空
|
||||
// 如果销售类别是"淘汰销售"或"淘汰屠宰",则疾病类型不能为空
|
||||
if ("淘汰销售".equals(saleType) || "淘汰屠宰".equals(saleType)) {
|
||||
if (sxSheepSale.getDiseaseType() == null) {
|
||||
if (sxSheepSale.getDiseaseType() == null || sxSheepSale.getDiseaseType().trim().isEmpty()) {
|
||||
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择疾病类型!");
|
||||
}
|
||||
if (sxSheepSale.getGroupCode() == null) {
|
||||
throw new RuntimeException("淘汰销售或淘汰屠宰必须选择班组!");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果疾病类型是"病残羊",则次要原因不能为空
|
||||
if ("病残羊".equals(sxSheepSale.getDiseaseType())) {
|
||||
if (sxSheepSale.getSecondaryReason() == null || sxSheepSale.getSecondaryReason().trim().isEmpty()) {
|
||||
|
||||
@@ -38,6 +38,17 @@
|
||||
<result property="remark" column="remark" />
|
||||
<result property="userId" column="user_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>
|
||||
|
||||
<sql id="selectSxSheepSaleVo">
|
||||
@@ -45,6 +56,85 @@
|
||||
from sx_sheep_sale s
|
||||
</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">
|
||||
select
|
||||
bs_manage_tags,
|
||||
@@ -57,7 +147,8 @@
|
||||
post_lambing_day,
|
||||
lactation_day,
|
||||
lambing_day,
|
||||
sheepfold_id
|
||||
sheepfold_id,
|
||||
current_weight
|
||||
from sheep_file
|
||||
</sql>
|
||||
|
||||
@@ -66,22 +157,18 @@
|
||||
where bs_manage_tags = #{bsManageTags}
|
||||
</select>
|
||||
|
||||
<select id="selectSxSheepSaleList" parameterType="SxSheepSale" resultMap="SxSheepSaleResult">
|
||||
<include refid="selectSxSheepSaleVo"/>
|
||||
<where>
|
||||
<if test="bsManageTags != null and bsManageTags != ''"> and s.bs_manage_tags = #{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="saleDate != null"> and s.sale_date = #{saleDate}</if>
|
||||
<if test="saleType != null and saleType != ''"> and s.sale_type = #{saleType}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
<select id="selectSheepTagsBySheepfoldId" parameterType="Long" resultType="String">
|
||||
SELECT bs_manage_tags
|
||||
FROM sheep_file
|
||||
WHERE sheepfold_id = #{sheepfoldId}
|
||||
</select>
|
||||
|
||||
<select id="selectSxSheepSaleById" parameterType="Long" resultMap="SxSheepSaleResult">
|
||||
<include refid="selectSxSheepSaleVo"/>
|
||||
where s.id = #{id}
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT bs_manage_tags
|
||||
FROM sheep_file
|
||||
WHERE bs_manage_tags LIKE CONCAT(#{query}, '%')
|
||||
ORDER BY bs_manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
<insert id="insertSxSheepSale" parameterType="SxSheepSale" useGeneratedKeys="true" keyProperty="id">
|
||||
|
||||
Reference in New Issue
Block a user