Merge remote-tracking branch 'origin/main'

This commit is contained in:
2026-02-03 22:15:05 +08:00
46 changed files with 1069 additions and 1209 deletions

View File

@@ -23,8 +23,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 鲜奶生产成品检验记录Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-18
*/
@RestController
@@ -77,6 +76,11 @@ public class NpFreshMilkInspController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpFreshMilkInsp npFreshMilkInsp)
{
// === 修改开始注入当前用户和部门ID ===
npFreshMilkInsp.setUserId(getUserId());
npFreshMilkInsp.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npFreshMilkInspService.insertNpFreshMilkInsp(npFreshMilkInsp));
}
@@ -96,9 +100,9 @@ public class NpFreshMilkInspController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('freshMilkTest:freshMilkTest:remove')")
@Log(title = "鲜奶生产,成品检验记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npFreshMilkInspService.deleteNpFreshMilkInspByIds(ids));
}
}
}

View File

@@ -28,11 +28,10 @@ public class NpMilkProdClassesController extends BaseController {
public TableDataInfo list(
@RequestParam(required = false) Date datetimeStart,
@RequestParam(required = false) Date datetimeEnd,
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号数组
@RequestParam(required = false) List<String> allEarNumbers,
@RequestParam(required = false) String factory,
@RequestParam(required = false) Integer classes) {
startPage();
// 修改处:将参数封装进实体,以便 Service 和 Mapper 统一处理
NpMilkProdClasses params = new NpMilkProdClasses();
params.setAllEarNumbers(allEarNumbers);
params.setFactory(factory);
@@ -43,9 +42,6 @@ public class NpMilkProdClassesController extends BaseController {
return getDataTable(list);
}
/**
* 修改处:新增耳号模糊查询接口
*/
@PreAuthorize("@ss.hasPermi('milkProdclasses:milkProdclasses:list')")
@GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
@@ -64,6 +60,16 @@ public class NpMilkProdClassesController extends BaseController {
try {
ExcelUtil<NpMilkProdClasses> util = new ExcelUtil<>(NpMilkProdClasses.class);
List<NpMilkProdClasses> list = util.importExcel(file.getInputStream());
// === 修改开始循环注入当前用户和部门ID ===
Long userId = getUserId();
Long deptId = getDeptId();
for (NpMilkProdClasses item : list) {
item.setUserId(userId);
item.setDeptId(deptId);
}
// === 修改结束 ===
int rows = npMilkProdClassesService.importMilkProdClasses(list);
return success("成功导入 " + rows + " 行数据");
} catch (Exception e) {
@@ -77,7 +83,7 @@ public class NpMilkProdClassesController extends BaseController {
public void export(HttpServletResponse response,
@RequestParam(required = false) Date datetimeStart,
@RequestParam(required = false) Date datetimeEnd,
@RequestParam(required = false) List<String> allEarNumbers, // 修改处:接收多耳号
@RequestParam(required = false) List<String> allEarNumbers,
@RequestParam(required = false) String factory,
@RequestParam(required = false) Integer classes) {

View File

@@ -24,8 +24,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 生乳检验记录Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
@RestController
@@ -78,6 +77,11 @@ public class NpRawMilkInspeController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpRawMilkInspe npRawMilkInspe)
{
// === 修改开始注入当前用户和部门ID ===
npRawMilkInspe.setUserId(getUserId());
npRawMilkInspe.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npRawMilkInspeService.insertNpRawMilkInspe(npRawMilkInspe));
}
@@ -97,9 +101,9 @@ public class NpRawMilkInspeController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('rawMilkTest:rawMilkTest:remove')")
@Log(title = "生乳检验记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npRawMilkInspeService.deleteNpRawMilkInspeByIds(ids));
}
}
}

View File

@@ -24,8 +24,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 酸奶生产成品检疫记录Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-17
*/
@RestController
@@ -78,6 +77,11 @@ public class NpYogurtInspController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody NpYogurtInsp npYogurtInsp)
{
// === 修改开始注入当前用户和部门ID ===
npYogurtInsp.setUserId(getUserId());
npYogurtInsp.setDeptId(getDeptId());
// === 修改结束 ===
return toAjax(npYogurtInspService.insertNpYogurtInsp(npYogurtInsp));
}
@@ -97,9 +101,9 @@ public class NpYogurtInspController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('yogurtTest:yogurtTest:remove')")
@Log(title = "酸奶生产,成品检疫记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(npYogurtInspService.deleteNpYogurtInspByIds(ids));
}
}
}

View File

@@ -23,8 +23,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 干物质校正Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-12
*/
@RestController
@@ -77,6 +76,9 @@ public class XzDryMatterCorrectionController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody XzDryMatterCorrection xzDryMatterCorrection)
{
// 自动填充用户ID和部门ID
xzDryMatterCorrection.setUserId(getUserId());
xzDryMatterCorrection.setDeptId(getDeptId());
return toAjax(xzDryMatterCorrectionService.insertXzDryMatterCorrection(xzDryMatterCorrection));
}
@@ -96,9 +98,9 @@ public class XzDryMatterCorrectionController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('dryMatterCorrection:dryMatterCorrection:remove')")
@Log(title = "干物质校正", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xzDryMatterCorrectionService.deleteXzDryMatterCorrectionByIds(ids));
}
}
}

View File

@@ -24,8 +24,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 称重校正Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-12
*/
@RestController
@@ -78,6 +77,9 @@ public class XzWegihCorrectionController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody XzWegihCorrection xzWegihCorrection)
{
// 自动填充用户ID和部门ID
xzWegihCorrection.setUserId(getUserId());
xzWegihCorrection.setDeptId(getDeptId());
return toAjax(xzWegihCorrectionService.insertXzWegihCorrection(xzWegihCorrection));
}
@@ -97,9 +99,9 @@ public class XzWegihCorrectionController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('weightCorrection:weightCorrection:remove')")
@Log(title = "称重校正", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(xzWegihCorrectionService.deleteXzWegihCorrectionByIds(ids));
}
}
}

View File

@@ -10,8 +10,7 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 鲜奶生产,成品检验记录对象 np_fresh_milk_insp
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-18
*/
@Data
@@ -85,4 +84,12 @@ public class NpFreshMilkInsp extends BaseEntity
@Excel(name = "备注")
private String commnet;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}

View File

@@ -65,6 +65,14 @@ public class NpMilkInOutStore extends BaseEntity {
@Excel(name = "爱特退回酸奶")
private BigDecimal returnYogurt;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
// --- getters and setters ---
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
@@ -125,4 +133,10 @@ public class NpMilkInOutStore extends BaseEntity {
public BigDecimal getReturnYogurt() { return returnYogurt; }
public void setReturnYogurt(BigDecimal returnYogurt) { this.returnYogurt = returnYogurt; }
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

@@ -2,7 +2,7 @@ package com.zhyc.module.dairyProducts.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List; // 引入 List
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel;
@@ -40,11 +40,19 @@ public class NpMilkProdClasses implements Serializable {
private String sheepId;
// 修改处:新增字段用于多耳号查询
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
// Getters and Setters
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
// --- Getters and Setters ---
public List<String> getAllEarNumbers() {
return allEarNumbers;
}
@@ -88,4 +96,10 @@ public class NpMilkProdClasses implements Serializable {
public String getSheepId() { return sheepId; }
public void setSheepId(String sheepId) { this.sheepId = sheepId; }
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

@@ -451,4 +451,12 @@ public class NpRawMilkInspe extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}

View File

@@ -10,8 +10,7 @@ import com.zhyc.common.core.domain.BaseEntity;
/**
* 酸奶生产,成品检疫记录对象 np_yogurt_insp
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-17
*/
@Data
@@ -42,7 +41,7 @@ public class NpYogurtInsp extends BaseEntity
private Double protein;
/** 非脂g/100g
*/
*/
@Excel(name = "非脂g/100g")
private Double nonFat;
@@ -86,4 +85,12 @@ public class NpYogurtInsp extends BaseEntity
@Excel(name = "备注")
private String comment;
}
/** 用户ID */
@Excel(name = "用户编号", type = Excel.Type.IMPORT)
private Long userId;
/** 部门ID */
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
private Long deptId;
}

View File

@@ -32,4 +32,9 @@ public class XzDryMatterCorrection extends BaseEntity {
@Excel(name = "干物质系数")
private Double coefficient;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
}

View File

@@ -45,5 +45,9 @@ public class XzWegihCorrection extends BaseEntity
@Excel(name = "称重系数")
private Double coefficient;
/** 用户ID */
private Long userId;
/** 部门ID */
private Long deptId;
}

View File

@@ -8,16 +8,49 @@ import java.util.List;
import java.util.Map;
public interface NpMilkInOutStoreMapper {
/**
* 动态列查询
*/
List<Map<String,Object>> selectWithColumns(
@Param("start") Date start, @Param("end") Date end,
@Param("feedSources") List<String> feedSources,
@Param("saleDestinations") List<String> saleDestinations
);
/**
* 插入主表
*/
int insertStore(NpMilkInOutStore store);
void insertFeedRecord(@Param("storeId") Integer storeId, @Param("source") String source, @Param("amount") java.math.BigDecimal amount);
void insertSaleRecord(@Param("storeId") Integer storeId, @Param("destination") String dest, @Param("amount") java.math.BigDecimal amount);
/**
* 插入饲喂子表(已修正:增加 userId 和 deptId 参数)
*/
void insertFeedRecord(
@Param("storeId") Integer storeId,
@Param("source") String source,
@Param("amount") java.math.BigDecimal amount,
@Param("userId") Long userId,
@Param("deptId") Long deptId
);
/**
* 插入销售子表(已修正:增加 userId 和 deptId 参数)
*/
void insertSaleRecord(
@Param("storeId") Integer storeId,
@Param("destination") String dest,
@Param("amount") java.math.BigDecimal amount,
@Param("userId") Long userId,
@Param("deptId") Long deptId
);
/**
* 获取饲喂来源列表(用于动态列头)
*/
List<String> selectFeedSources();
List<String> selectSaleDestinations();
}
/**
* 获取销售去向列表(用于动态列头)
*/
List<String> selectSaleDestinations();
}

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.NpFreshMilkInspMapper;
@@ -10,20 +11,18 @@ import com.zhyc.module.dairyProducts.service.INpFreshMilkInspService;
/**
* 鲜奶生产成品检验记录Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-18
*/
@Service
public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
{
@Autowired
private NpFreshMilkInspMapper npFreshMilkInspMapper;
/**
* 查询鲜奶生产,成品检验记录
*
* @param id 鲜奶生产,成品检验记录主键
* * @param id 鲜奶生产,成品检验记录主键
* @return 鲜奶生产,成品检验记录
*/
@Override
@@ -34,11 +33,11 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 查询鲜奶生产,成品检验记录列表
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 鲜奶生产,成品检验记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpFreshMilkInsp> selectNpFreshMilkInspList(NpFreshMilkInsp npFreshMilkInsp)
{
return npFreshMilkInspMapper.selectNpFreshMilkInspList(npFreshMilkInsp);
@@ -46,8 +45,7 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 新增鲜奶生产,成品检验记录
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 结果
*/
@Override
@@ -59,8 +57,7 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 修改鲜奶生产,成品检验记录
*
* @param npFreshMilkInsp 鲜奶生产,成品检验记录
* * @param npFreshMilkInsp 鲜奶生产,成品检验记录
* @return 结果
*/
@Override
@@ -71,8 +68,7 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 批量删除鲜奶生产,成品检验记录
*
* @param ids 需要删除的鲜奶生产,成品检验记录主键
* * @param ids 需要删除的鲜奶生产,成品检验记录主键
* @return 结果
*/
@Override
@@ -83,8 +79,7 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
/**
* 删除鲜奶生产,成品检验记录信息
*
* @param id 鲜奶生产,成品检验记录主键
* * @param id 鲜奶生产,成品检验记录主键
* @return 结果
*/
@Override
@@ -92,4 +87,4 @@ public class NpFreshMilkInspServiceImpl implements INpFreshMilkInspService
{
return npFreshMilkInspMapper.deleteNpFreshMilkInspById(id);
}
}
}

View File

@@ -1,5 +1,7 @@
package com.zhyc.module.dairyProducts.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.dairyProducts.domain.NpMilkInOutStore;
import com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper;
import com.zhyc.module.dairyProducts.service.INpMilkInOutStoreService;
@@ -19,6 +21,7 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
private NpMilkInOutStoreMapper mapper;
@Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Map<String, Object>> selectWithDynamicColumns(Date start, Date end) {
List<String> feed = mapper.selectFeedSources();
List<String> sale = mapper.selectSaleDestinations();
@@ -58,25 +61,46 @@ public class NpMilkInOutStoreServiceImpl implements INpMilkInOutStoreService {
@Override
public void batchInsertFromRows(List<Map<String, Object>> rows) throws Exception {
// === 修改开始获取当前用户和部门ID ===
Long userId = SecurityUtils.getUserId();
Long deptId = SecurityUtils.getDeptId();
// === 修改结束 ===
for (Map<String,Object> row : rows) {
// 提取主表字段
NpMilkInOutStore store = new NpMilkInOutStore();
// 这里假设 Excel 中的"日期"格式是标准的 yyyy-MM-dd如果格式不对可能会报错建议加 try-catch 或格式化处理
store.setDatetime(java.sql.Date.valueOf(row.get("日期").toString()));
store.setNum(Integer.valueOf(row.get("羊数").toString()));
// ... 设置其它固定字段 ...
// 手动填充其它主表字段,这里省略了具体的 get 调用,请根据您的 Excel 列名自行补充
// store.setColostSheep(...);
// === 修改开始给主表实体注入用户和部门ID ===
store.setUserId(userId);
store.setDeptId(deptId);
// === 修改结束 ===
mapper.insertStore(store);
Integer sid = store.getId();
// 其余列为动态饲喂或销售,根据字典决定分类:
for (Map.Entry<String,Object> ent: row.entrySet()) {
String col = ent.getKey();
// 跳过固定列
if (col.equals("日期") || col.equals("羊数") || col.equals("id")) continue;
if (ent.getValue() == null || "".equals(ent.getValue().toString())) continue;
BigDecimal amt = new BigDecimal(ent.getValue().toString());
if (mapper.selectFeedSources().contains(col)) {
mapper.insertFeedRecord(sid, col, amt);
// === 修改开始:插入饲喂子表时传入 userId 和 deptId ===
mapper.insertFeedRecord(sid, col, amt, userId, deptId);
} else if (mapper.selectSaleDestinations().contains(col)) {
mapper.insertSaleRecord(sid, col, amt);
// === 修改开始:插入销售子表时传入 userId 和 deptId ===
mapper.insertSaleRecord(sid, col, amt, userId, deptId);
}
}
}
}
}
}

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.dairyProducts.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.dairyProducts.domain.NpMilkProdClasses;
import com.zhyc.module.dairyProducts.mapper.NpMilkProdClassesMapper;
import com.zhyc.module.dairyProducts.service.INpMilkProdClassesService;
@@ -16,6 +17,7 @@ public class NpMilkProdClassesServiceImpl implements INpMilkProdClassesService {
private NpMilkProdClassesMapper mapper;
@Override
@DataScope(deptAlias = "mpc", userAlias = "mpc")
public List<NpMilkProdClasses> selectNpMilkProdClassesList(NpMilkProdClasses npMilkProdClasses, Date datetimeStart, Date datetimeEnd) {
// 修改处:传递实体对象
return mapper.selectNpMilkProdClassesList(npMilkProdClasses, datetimeStart, datetimeEnd);

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.NpRawMilkInspeMapper;
@@ -10,20 +11,18 @@ import com.zhyc.module.dairyProducts.service.INpRawMilkInspeService;
/**
* 生乳检验记录Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
@Service
public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
{
@Autowired
private NpRawMilkInspeMapper npRawMilkInspeMapper;
/**
* 查询生乳检验记录
*
* @param id 生乳检验记录主键
* * @param id 生乳检验记录主键
* @return 生乳检验记录
*/
@Override
@@ -34,11 +33,11 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 查询生乳检验记录列表
*
* @param npRawMilkInspe 生乳检验记录
* * @param npRawMilkInspe 生乳检验记录
* @return 生乳检验记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpRawMilkInspe> selectNpRawMilkInspeList(NpRawMilkInspe npRawMilkInspe)
{
return npRawMilkInspeMapper.selectNpRawMilkInspeList(npRawMilkInspe);
@@ -46,8 +45,7 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 新增生乳检验记录
*
* @param npRawMilkInspe 生乳检验记录
* * @param npRawMilkInspe 生乳检验记录
* @return 结果
*/
@Override
@@ -59,8 +57,7 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 修改生乳检验记录
*
* @param npRawMilkInspe 生乳检验记录
* * @param npRawMilkInspe 生乳检验记录
* @return 结果
*/
@Override
@@ -71,8 +68,7 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 批量删除生乳检验记录
*
* @param ids 需要删除的生乳检验记录主键
* * @param ids 需要删除的生乳检验记录主键
* @return 结果
*/
@Override
@@ -83,8 +79,7 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
/**
* 删除生乳检验记录信息
*
* @param id 生乳检验记录主键
* * @param id 生乳检验记录主键
* @return 结果
*/
@Override
@@ -92,4 +87,4 @@ public class NpRawMilkInspeServiceImpl implements INpRawMilkInspeService
{
return npRawMilkInspeMapper.deleteNpRawMilkInspeById(id);
}
}
}

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.dairyProducts.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.dairyProducts.domain.NpYogurtInsp;
import com.zhyc.module.dairyProducts.mapper.NpYogurtInspMapper;
import com.zhyc.module.dairyProducts.service.INpYogurtInspService;
@@ -10,8 +11,7 @@ import org.springframework.stereotype.Service;
/**
* 酸奶生产成品检疫记录Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-17
*/
@Service
@@ -22,8 +22,7 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 查询酸奶生产,成品检疫记录
*
* @param id 酸奶生产,成品检疫记录主键
* * @param id 酸奶生产,成品检疫记录主键
* @return 酸奶生产,成品检疫记录
*/
@Override
@@ -34,11 +33,11 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 查询酸奶生产,成品检疫记录列表
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 酸奶生产,成品检疫记录
*/
@Override
@DataScope(deptAlias = "a", userAlias = "a")
public List<NpYogurtInsp> selectNpYogurtInspList(NpYogurtInsp npYogurtInsp)
{
return npYogurtInspMapper.selectNpYogurtInspList(npYogurtInsp);
@@ -46,8 +45,7 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 新增酸奶生产,成品检疫记录
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果
*/
@Override
@@ -59,8 +57,7 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 修改酸奶生产,成品检疫记录
*
* @param npYogurtInsp 酸奶生产,成品检疫记录
* * @param npYogurtInsp 酸奶生产,成品检疫记录
* @return 结果
*/
@Override
@@ -71,8 +68,7 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 批量删除酸奶生产,成品检疫记录
*
* @param ids 需要删除的酸奶生产,成品检疫记录主键
* * @param ids 需要删除的酸奶生产,成品检疫记录主键
* @return 结果
*/
@Override
@@ -83,8 +79,7 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
/**
* 删除酸奶生产,成品检疫记录信息
*
* @param id 酸奶生产,成品检疫记录主键
* * @param id 酸奶生产,成品检疫记录主键
* @return 结果
*/
@Override
@@ -92,4 +87,4 @@ public class NpYogurtInspServiceImpl implements INpYogurtInspService
{
return npYogurtInspMapper.deleteNpYogurtInspById(id);
}
}
}

View File

@@ -6,23 +6,22 @@ import org.springframework.stereotype.Service;
import com.zhyc.module.dairyProducts.mapper.XzDryMatterCorrectionMapper;
import com.zhyc.module.dairyProducts.domain.XzDryMatterCorrection;
import com.zhyc.module.dairyProducts.service.IXzDryMatterCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
/**
* 干物质校正Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-12
*/
@Service
public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService
public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionService
{
@Autowired
private XzDryMatterCorrectionMapper xzDryMatterCorrectionMapper;
/**
* 查询干物质校正
*
* @param id 干物质校正主键
* * @param id 干物质校正主键
* @return 干物质校正
*/
@Override
@@ -33,11 +32,11 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 查询干物质校正列表
*
* @param xzDryMatterCorrection 干物质校正
* * @param xzDryMatterCorrection 干物质校正
* @return 干物质校正
*/
@Override
@DataScope(deptAlias = "d", userAlias = "d") // 添加数据权限注解
public List<XzDryMatterCorrection> selectXzDryMatterCorrectionList(XzDryMatterCorrection xzDryMatterCorrection)
{
return xzDryMatterCorrectionMapper.selectXzDryMatterCorrectionList(xzDryMatterCorrection);
@@ -102,8 +101,7 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 批量删除干物质校正
*
* @param ids 需要删除的干物质校正主键
* * @param ids 需要删除的干物质校正主键
* @return 结果
*/
@Override
@@ -114,8 +112,7 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
/**
* 删除干物质校正信息
*
* @param id 干物质校正主键
* * @param id 干物质校正主键
* @return 结果
*/
@Override
@@ -123,4 +120,4 @@ public class XzDryMatterCorrectionServiceImpl implements IXzDryMatterCorrectionS
{
return xzDryMatterCorrectionMapper.deleteXzDryMatterCorrectionById(id);
}
}
}

View File

@@ -8,13 +8,13 @@ import com.zhyc.common.exception.ServiceException;
import com.zhyc.module.dairyProducts.domain.XzWegihCorrection;
import com.zhyc.module.dairyProducts.mapper.XzWegihCorrectionMapper;
import com.zhyc.module.dairyProducts.service.IXzWegihCorrectionService;
import com.zhyc.common.annotation.DataScope; // 引入数据权限注解
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 称重校正Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-12
*/
@Service
@@ -25,8 +25,7 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 查询称重校正
*
* @param id 称重校正主键
* * @param id 称重校正主键
* @return 称重校正
*/
@Override
@@ -37,11 +36,11 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 查询称重校正列表
*
* @param xzWegihCorrection 称重校正
* * @param xzWegihCorrection 称重校正
* @return 称重校正
*/
@Override
@DataScope(deptAlias = "w", userAlias = "w") // 添加数据权限注解
public List<XzWegihCorrection> selectXzWegihCorrectionList(XzWegihCorrection xzWegihCorrection)
{
return xzWegihCorrectionMapper.selectXzWegihCorrectionList(xzWegihCorrection);
@@ -106,8 +105,7 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 批量删除称重校正
*
* @param ids 需要删除的称重校正主键
* * @param ids 需要删除的称重校正主键
* @return 结果
*/
@Override
@@ -118,8 +116,7 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
/**
* 删除称重校正信息
*
* @param id 称重校正主键
* * @param id 称重校正主键
* @return 结果
*/
@Override
@@ -127,4 +124,4 @@ public class XzWegihCorrectionServiceImpl implements IXzWegihCorrectionService
{
return xzWegihCorrectionMapper.deleteXzWegihCorrectionById(id);
}
}
}

View File

@@ -1,9 +1,8 @@
package com.zhyc.module.produce.breed.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,8 +28,7 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 干奶记录Controller
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
@RestController
@@ -51,24 +49,55 @@ public class ScDryMilkController extends BaseController
public TableDataInfo list(ScDryMilk scDryMilk)
{
try {
// 添加调试日志
// 处理耳号多选:将逗号/空格分隔的字符串转为List
if (scDryMilk.getManageTags() != null && !scDryMilk.getManageTags().trim().isEmpty()) {
logger.info("搜索耳号参数: [{}]", scDryMilk.getManageTags());
scDryMilk.setManageTags(scDryMilk.getManageTags().trim());
if (scDryMilk.getManageTagsList() == null) {
scDryMilk.setManageTagsList(new ArrayList<>());
}
String[] tags = scDryMilk.getManageTags().trim().split("[,\\s]+");
scDryMilk.getManageTagsList().addAll(Arrays.asList(tags));
}
// 处理技术员多选将逗号分隔的字符串转为List
if (scDryMilk.getTecahnician() != null && !scDryMilk.getTecahnician().trim().isEmpty()) {
if (scDryMilk.getTechnicianList() == null) {
scDryMilk.setTechnicianList(new ArrayList<>());
}
String[] techs = scDryMilk.getTecahnician().trim().split("[,\\s]+");
scDryMilk.getTechnicianList().addAll(Arrays.asList(techs));
}
startPage();
List<ScDryMilk> list = scDryMilkService.selectScDryMilkList(scDryMilk);
logger.info("查询到干奶记录数量: {}", list.size());
return getDataTable(list);
} catch (Exception e) {
logger.error("查询干奶记录列表失败", e);
return getDataTable(new java.util.ArrayList<>());
return getDataTable(new ArrayList<>());
}
}
/**
* 远程搜索耳号列表
*/
@GetMapping("/searchEarNumbers")
public AjaxResult searchEarNumbers(@RequestParam(value = "query", required = false) String query)
{
if (query == null) query = "";
List<String> list = scDryMilkService.selectSheepEarNumberList(query);
return AjaxResult.success(list);
}
/**
* 远程搜索技术员列表
*/
@GetMapping("/searchTechnicians")
public AjaxResult searchTechnicians(@RequestParam(value = "query", required = false) String query)
{
if (query == null) query = "";
List<String> list = scDryMilkService.selectTechnicianList(query);
return AjaxResult.success(list);
}
/**
* 导出干奶记录列表
*/
@@ -78,8 +107,14 @@ public class ScDryMilkController extends BaseController
public void export(HttpServletResponse response, ScDryMilk scDryMilk)
{
try {
// 导出也需要支持多选查询
if (scDryMilk.getManageTags() != null) {
scDryMilk.setManageTags(scDryMilk.getManageTags().trim());
String[] tags = scDryMilk.getManageTags().trim().split("[,\\s]+");
scDryMilk.setManageTagsList(Arrays.asList(tags));
}
if (scDryMilk.getTecahnician() != null) {
String[] techs = scDryMilk.getTecahnician().trim().split("[,\\s]+");
scDryMilk.setTechnicianList(Arrays.asList(techs));
}
List<ScDryMilk> list = scDryMilkService.selectScDryMilkList(scDryMilk);
@@ -97,90 +132,21 @@ public class ScDryMilkController extends BaseController
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
try {
if (id == null) {
return error("记录ID不能为空");
}
ScDryMilk result = scDryMilkService.selectScDryMilkById(id);
if (result == null) {
return error("记录不存在");
}
return success(result);
} catch (Exception e) {
logger.error("获取干奶记录详细信息失败ID: " + id, e);
return error("获取记录详细信息失败: " + e.getMessage());
}
return success(scDryMilkService.selectScDryMilkById(id));
}
/**
* 根据耳号查询羊只ID - 新增耳号验证功能
*/
@GetMapping("/validateEarTag")
public AjaxResult validateEarTag(@RequestParam("manageTags") String manageTags)
{
try {
if (manageTags == null || manageTags.trim().isEmpty()) {
return error("耳号不能为空");
}
String cleanTag = manageTags.trim();
logger.info("验证耳号: [{}]", cleanTag);
Long sheepId = scDryMilkService.selectSheepIdByManageTags(cleanTag);
if (sheepId == null) {
logger.warn("耳号 [{}] 不存在", cleanTag);
return error("该耳号不存在,请检查输入");
}
logger.info("验证耳号成功羊只ID: {}", sheepId);
return AjaxResult.success("耳号验证通过", sheepId);
} catch (Exception e) {
logger.error("验证耳号失败,耳号: " + manageTags, e);
return error("验证耳号时出错: " + e.getMessage());
}
}
/**
* 根据耳号查询羊只ID
*/
@PreAuthorize("@ss.hasPermi('drymilk:drymilk:query')")
@GetMapping(value = "/sheep/{manageTags}")
public AjaxResult getSheepIdByManageTags(@PathVariable("manageTags") String manageTags)
{
Long sheepId = scDryMilkService.selectSheepIdByManageTags(manageTags);
return success(sheepId);
}
/**
* 获取羊舍列表 - 用于嵌套选择
* 获取羊舍列表
*/
@GetMapping("/sheepfoldList")
public AjaxResult getSheepfoldList(@RequestParam(value = "ranchId", required = false) Long ranchId,
@RequestParam(value = "sheepfoldTypeId", required = false) Long sheepfoldTypeId)
public AjaxResult getSheepfoldList(DaSheepfold daSheepfold)
{
try {
DaSheepfold query = new DaSheepfold();
if (ranchId != null) {
query.setRanchId(ranchId);
}
if (sheepfoldTypeId != null) {
query.setSheepfoldTypeId(sheepfoldTypeId);
}
List<DaSheepfold> sheepfoldList = daSheepfoldService.selectDaSheepfoldList(query);
logger.info("查询羊舍列表牧场ID: {}, 类型ID: {}, 结果数量: {}", ranchId, sheepfoldTypeId, sheepfoldList.size());
return success(sheepfoldList);
} catch (Exception e) {
logger.error("获取羊舍列表失败", e);
return error("获取羊舍列表失败: " + e.getMessage());
}
List<DaSheepfold> list = daSheepfoldService.selectDaSheepfoldList(daSheepfold);
return success(list);
}
/**
* 新增干奶记录
* 新增干奶记录 (支持批量录入)
*/
@PreAuthorize("@ss.hasPermi('drymilk:drymilk:add')")
@Log(title = "干奶记录", businessType = BusinessType.INSERT)
@@ -188,43 +154,41 @@ public class ScDryMilkController extends BaseController
public AjaxResult add(@RequestBody ScDryMilk scDryMilk)
{
try {
// 基础参数校验
if (scDryMilk == null) {
return error("请求参数不能为空");
}
if (scDryMilk.getManageTags() == null || scDryMilk.getManageTags().trim().isEmpty()) {
if (scDryMilk == null || scDryMilk.getManageTags() == null) {
return error("耳号不能为空");
}
if (scDryMilk.getDatetime() == null) {
return error("干奶日期不能为空");
// 批量解析耳号
String[] tags = scDryMilk.getManageTags().trim().split("[\\s,\n]+");
int successCount = 0;
StringBuilder errorMsg = new StringBuilder();
for (String tag : tags) {
if (tag.isEmpty()) continue;
Long sheepId = scDryMilkService.selectSheepIdByManageTags(tag);
if (sheepId == null) {
errorMsg.append(tag).append("不存在; ");
continue;
}
ScDryMilk newItem = new ScDryMilk();
newItem.setSheepId(String.valueOf(sheepId));
newItem.setDatetime(scDryMilk.getDatetime());
newItem.setStatus(scDryMilk.getStatus());
newItem.setSheepfold(scDryMilk.getSheepfold());
newItem.setTecahnician(scDryMilk.getTecahnician());
newItem.setComment(scDryMilk.getComment());
newItem.setCreateBy(getUsername());
scDryMilkService.insertScDryMilk(newItem);
successCount++;
}
if (scDryMilk.getStatus() == null) {
return error("请选择是否使用乳头封闭剂");
}
// 清理输入参数
scDryMilk.setManageTags(scDryMilk.getManageTags().trim());
if (scDryMilk.getTecahnician() != null) {
scDryMilk.setTecahnician(scDryMilk.getTecahnician().trim());
}
if (scDryMilk.getComment() != null) {
scDryMilk.setComment(scDryMilk.getComment().trim());
}
logger.info("新增干奶记录,耳号: {}", scDryMilk.getManageTags());
int result = scDryMilkService.insertScDryMilk(scDryMilk);
if (result > 0) {
// 重新查询插入的记录,包含自动生成的创建时间
ScDryMilk insertedRecord = scDryMilkService.selectScDryMilkById(scDryMilk.getId());
logger.info("新增干奶记录成功记录ID: {}", scDryMilk.getId());
return success(insertedRecord);
} else {
return error("新增失败");
if (errorMsg.length() > 0) {
return warn("成功录入 " + successCount + " 条。失败详情:" + errorMsg.toString());
}
return success("成功录入 " + successCount + " 条记录");
} catch (Exception e) {
logger.error("新增干奶记录失败", e);
return error("新增失败: " + e.getMessage());
@@ -239,39 +203,7 @@ public class ScDryMilkController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody ScDryMilk scDryMilk)
{
try {
if (scDryMilk == null) {
return error("请求参数不能为空");
}
if (scDryMilk.getId() == null) {
return error("记录ID不能为空");
}
// 清理输入参数
if (scDryMilk.getManageTags() != null) {
scDryMilk.setManageTags(scDryMilk.getManageTags().trim());
}
if (scDryMilk.getTecahnician() != null) {
scDryMilk.setTecahnician(scDryMilk.getTecahnician().trim());
}
if (scDryMilk.getComment() != null) {
scDryMilk.setComment(scDryMilk.getComment().trim());
}
logger.info("修改干奶记录ID: {}", scDryMilk.getId());
int result = scDryMilkService.updateScDryMilk(scDryMilk);
if (result > 0) {
logger.info("修改干奶记录成功");
return success("修改成功");
} else {
return error("修改失败,记录可能不存在");
}
} catch (Exception e) {
logger.error("修改干奶记录失败", e);
return error("修改失败: " + e.getMessage());
}
return toAjax(scDryMilkService.updateScDryMilk(scDryMilk));
}
/**
@@ -282,71 +214,6 @@ public class ScDryMilkController extends BaseController
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
try {
if (ids == null || ids.length == 0) {
return error("删除的记录ID不能为空");
}
logger.info("删除干奶记录IDs: {}", java.util.Arrays.toString(ids));
int result = scDryMilkService.deleteScDryMilkByIds(ids);
if (result > 0) {
logger.info("删除干奶记录成功,删除数量: {}", result);
return success("删除成功");
} else {
return error("删除失败,记录可能不存在");
}
} catch (Exception e) {
logger.error("删除干奶记录失败", e);
return error("删除失败: " + e.getMessage());
}
return toAjax(scDryMilkService.deleteScDryMilkByIds(ids));
}
@PreAuthorize("@ss.hasPermi('drymilk:drymilk:quary')")
@GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
List<String> earNumbers = scDryMilkService.searchEarNumbers(query);
return success(earNumbers);
} catch (Exception e) {
logger.error("搜索耳号异常", e);
return error("搜索耳号失败:" + e.getMessage());
}
}
/**
* 批量验证耳号
*/
@GetMapping("/validateBatchEarTags")
public AjaxResult validateBatchEarTags(@RequestParam("manageTags") String manageTags) {
try {
if (manageTags == null || manageTags.trim().isEmpty()) {
return error("耳号不能为空");
}
// 支持多种分隔符
String[] earTagArray = manageTags.split("[\\s,]+");
List<Map<String, Object>> results = new ArrayList<>();
for (String earTag : earTagArray) {
String cleanTag = earTag.trim();
if (cleanTag.isEmpty()) continue;
Map<String, Object> result = new HashMap<>();
result.put("earTag", cleanTag);
Long sheepId = scDryMilkService.selectSheepIdByManageTags(cleanTag);
result.put("exists", sheepId != null);
result.put("sheepId", sheepId);
results.add(result);
}
return success(results);
} catch (Exception e) {
logger.error("批量验证耳号失败", e);
return error("验证失败: " + e.getMessage());
}
}
}

View File

@@ -5,12 +5,19 @@ import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.common.exception.ServiceException;
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
import com.zhyc.module.produce.breed.service.IScSheepDeathService;
import com.zhyc.module.biosafety.service.ISwDiseaseService;
@@ -41,19 +48,35 @@ public class ScSheepDeathController extends BaseController
@GetMapping("/list")
public TableDataInfo list(ScSheepDeath scSheepDeath)
{
try {
startPage();
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
return getDataTable(list);
} catch (Exception e) {
logger.error("查询羊只死淘记录列表失败", e);
return getDataTable(new java.util.ArrayList<>());
}
startPage();
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
return getDataTable(list);
}
/**
* 根据管理耳号查询羊只信息
* 搜索管理耳号(用于下拉提示)
*/
@GetMapping("/search/earNo")
public AjaxResult searchEarNo(@RequestParam("query") String query) {
return success(scSheepDeathService.selectDistinctManageTags(query == null ? "" : query));
}
/**
* 搜索技术员(用于下拉提示)
*/
@GetMapping("/search/technician")
public AjaxResult searchTechnician(@RequestParam("query") String query) {
return success(scSheepDeathService.selectDistinctTechnician(query == null ? "" : query));
}
/**
* 搜索处理人(用于下拉提示)
*/
@GetMapping("/search/handler")
public AjaxResult searchHandler(@RequestParam("query") String query) {
return success(scSheepDeathService.selectDistinctHandler(query == null ? "" : query));
}
@PreAuthorize("@ss.hasPermi('sheep_death:death:query')")
@GetMapping("/sheepInfo/{manageTags}")
public AjaxResult getSheepInfo(@PathVariable("manageTags") String manageTags)
@@ -62,7 +85,6 @@ public class ScSheepDeathController extends BaseController
if (manageTags == null || manageTags.trim().isEmpty()) {
return error("管理耳号不能为空");
}
Map<String, Object> sheepInfo = scSheepDeathService.selectSheepFileByManageTags(manageTags.trim());
if (sheepInfo != null) {
return success(sheepInfo);
@@ -70,187 +92,63 @@ public class ScSheepDeathController extends BaseController
return error("未找到该耳号对应的羊只信息");
}
} catch (Exception e) {
logger.error("查询羊只信息失败,管理耳号: " + manageTags, e);
return error("查询羊只信息失败: " + e.getMessage());
}
}
/**
* 获取疾病树形列表
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:query')")
@GetMapping("/disease/tree")
public AjaxResult getDiseaseTree()
{
try {
List<SwDisease> diseaseList = swDiseaseService.selectSwDiseaseList(new SwDisease());
return success(diseaseList);
} catch (Exception e) {
logger.error("获取疾病树形列表失败", e);
return error("获取疾病列表失败: " + e.getMessage());
}
List<SwDisease> diseaseList = swDiseaseService.selectSwDiseaseList(new SwDisease());
return success(diseaseList);
}
/**
* 导出羊只死淘记录列表
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:export')")
@Log(title = "羊只死淘记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ScSheepDeath scSheepDeath)
{
try {
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
ExcelUtil<ScSheepDeath> util = new ExcelUtil<ScSheepDeath>(ScSheepDeath.class);
util.exportExcel(response, list, "羊只死淘记录数据");
} catch (Exception e) {
logger.error("导出羊只死淘记录失败", e);
// 可以在这里返回错误响应
}
List<ScSheepDeath> list = scSheepDeathService.selectScSheepDeathList(scSheepDeath);
ExcelUtil<ScSheepDeath> util = new ExcelUtil<ScSheepDeath>(ScSheepDeath.class);
util.exportExcel(response, list, "羊只死淘记录数据");
}
/**
* 获取羊只死淘记录详细信息
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
try {
if (id == null) {
return error("记录ID不能为空");
}
ScSheepDeath result = scSheepDeathService.selectScSheepDeathById(id);
if (result == null) {
return error("记录不存在");
}
return success(result);
} catch (Exception e) {
logger.error("获取羊只死淘记录详细信息失败ID: " + id, e);
return error("获取记录详细信息失败: " + e.getMessage());
}
return success(scSheepDeathService.selectScSheepDeathById(id));
}
/**
* 新增羊只死淘记录
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:add')")
@Log(title = "羊只死淘记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScSheepDeath scSheepDeath)
{
try {
// 基础参数校验
if (scSheepDeath == null) {
return error("请求参数不能为空");
}
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
if (scSheepDeath == null || scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
return error("管理耳号不能为空");
}
if (scSheepDeath.getDeathDate() == null) {
return error("死淘日期不能为空");
}
int result = scSheepDeathService.insertScSheepDeath(scSheepDeath);
if (result > 0) {
return success("新增成功");
} else {
return error("新增失败");
}
} catch (ServiceException e) {
logger.warn("新增羊只死淘记录业务异常: " + e.getMessage());
return error(e.getMessage());
return toAjax(scSheepDeathService.insertScSheepDeath(scSheepDeath));
} catch (Exception e) {
logger.error("新增羊只死淘记录失败", e);
return error("新增失败: " + e.getMessage());
}
}
/**
* 修改羊只死淘记录
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:edit')")
@Log(title = "羊只死淘记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScSheepDeath scSheepDeath)
{
try {
// 基础参数校验
if (scSheepDeath == null) {
return error("请求参数不能为空");
}
if (scSheepDeath.getId() == null) {
return error("记录ID不能为空");
}
if (scSheepDeath.getManageTags() == null || scSheepDeath.getManageTags().trim().isEmpty()) {
return error("管理耳号不能为空");
}
if (scSheepDeath.getDeathDate() == null) {
return error("死淘日期不能为空");
}
int result = scSheepDeathService.updateScSheepDeath(scSheepDeath);
if (result > 0) {
return success("修改成功");
} else {
return error("修改失败,记录可能不存在");
}
} catch (ServiceException e) {
logger.warn("修改羊只死淘记录业务异常: " + e.getMessage());
return error(e.getMessage());
} catch (Exception e) {
logger.error("修改羊只死淘记录失败", e);
return error("修改失败: " + e.getMessage());
}
return toAjax(scSheepDeathService.updateScSheepDeath(scSheepDeath));
}
/**
* 删除羊只死淘记录
*/
@PreAuthorize("@ss.hasPermi('sheep_death:death:remove')")
@Log(title = "羊只死淘记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
try {
if (ids == null || ids.length == 0) {
return error("删除的记录ID不能为空");
}
int result = scSheepDeathService.deleteScSheepDeathByIds(ids);
if (result > 0) {
return success("删除成功");
} else {
return error("删除失败,记录可能不存在");
}
} catch (ServiceException e) {
logger.warn("删除羊只死淘记录业务异常: " + e.getMessage());
return error(e.getMessage());
} catch (Exception e) {
logger.error("删除羊只死淘记录失败", e);
return error("删除失败: " + e.getMessage());
}
}
/**
* 模糊查询母羊耳号列表
*/
@PreAuthorize("@ss.hasPermi('breed:lambing_records:query')") // 根据实际权限修改
@GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
List<String> earNumbers = scSheepDeathService.searchEarNumbers(query);
return success(earNumbers);
} catch (Exception e) {
logger.error("搜索耳号异常", e);
return error("搜索耳号失败:" + e.getMessage());
}
return toAjax(scSheepDeathService.deleteScSheepDeathByIds(ids));
}
}

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.produce.breed.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.module.produce.breed.domain.ScWeanRecord;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,9 +18,6 @@ import com.zhyc.common.core.page.TableDataInfo;
/**
* 断奶记录Controller
*
* @author zhyc
* @date 2024-01-01
*/
@RestController
@RequestMapping("/Weaning/weaning_record")
@@ -38,6 +36,16 @@ public class ScWeanRecordController extends BaseController {
return getDataTable(list);
}
/**
* 【新增】模糊查询耳号列表 (用于前端下拉框远程搜索)
*/
@PreAuthorize("@ss.hasPermi('Weaning:weaning_record:list')")
@GetMapping("/search_ear_numbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
List<String> list = scWeanRecordService.searchEarNumbers(query);
return success(list);
}
/**
* 导出断奶记录列表
*/
@@ -80,7 +88,6 @@ public class ScWeanRecordController extends BaseController {
@Log(title = "断奶记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ScWeanRecord scWeanRecord) {
// 验证耳号是否存在
if (scWeanRecord.getEarNumber() != null) {
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId == null) {
@@ -88,20 +95,10 @@ public class ScWeanRecordController extends BaseController {
}
scWeanRecord.setSheepId(sheepId);
}
// 验证必要字段
if (scWeanRecord.getSheepId() == null) {
return error("羊只信息不能为空");
}
if (scWeanRecord.getDatetime() == null) {
return error("断奶日期不能为空");
}
if (scWeanRecord.getWeight() == null) {
return error("断奶重量不能为空");
}
if (scWeanRecord.getStatus() == null) {
return error("是否留养不能为空");
}
if (scWeanRecord.getSheepId() == null) return error("羊只信息不能为空");
if (scWeanRecord.getDatetime() == null) return error("断奶日期不能为空");
if (scWeanRecord.getWeight() == null) return error("断奶重量不能为空");
if (scWeanRecord.getStatus() == null) return error("是否留养不能为空");
scWeanRecord.setCreateBy(getUsername());
return toAjax(scWeanRecordService.insertScWeanRecord(scWeanRecord));
@@ -114,32 +111,11 @@ public class ScWeanRecordController extends BaseController {
@Log(title = "断奶记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ScWeanRecord scWeanRecord) {
// 验证耳号是否存在
if (scWeanRecord.getEarNumber() != null) {
Long sheepId = scWeanRecordService.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId == null) {
return error("耳号不存在,请检查后重新输入");
}
if (sheepId == null) return error("耳号不存在");
scWeanRecord.setSheepId(sheepId);
}
// 验证必要字段
if (scWeanRecord.getId() == null) {
return error("记录ID不能为空");
}
if (scWeanRecord.getSheepId() == null) {
return error("羊只信息不能为空");
}
if (scWeanRecord.getDatetime() == null) {
return error("断奶日期不能为空");
}
if (scWeanRecord.getWeight() == null) {
return error("断奶重量不能为空");
}
if (scWeanRecord.getStatus() == null) {
return error("是否留养不能为空");
}
return toAjax(scWeanRecordService.updateScWeanRecord(scWeanRecord));
}

View File

@@ -2,11 +2,9 @@ package com.zhyc.module.produce.breed.domain;
import java.util.Date;
import java.util.List;
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;
@@ -16,9 +14,6 @@ import com.zhyc.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2025-07-15
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ScDryMilk extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -35,8 +30,8 @@ public class ScDryMilk extends BaseEntity
@Excel(name = "干奶日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 是否使用乳头封闭剂 */
@Excel(name = "是否使用乳头封闭剂")
/** 是否使用乳头封闭剂 (1:是 0:否) */
@Excel(name = "是否使用乳头封闭剂", readConverterExp = "0=否,1=是")
private Long status;
/** 转入羊舍id */
@@ -51,12 +46,15 @@ public class ScDryMilk extends BaseEntity
@Excel(name = "备注")
private String comment;
// 以下为联表查询字段不存储在sc_dry_milk表中
// --- 联表查询及辅助字段 ---
/** 管理耳号 */
/** 管理耳号 (单个,用于接收前端传参或导出显示) */
@Excel(name = "耳号")
private String manageTags;
/** 多耳号查询列表 (用于MyBatis IN查询) */
private List<String> manageTagsList;
/** 品种 */
@Excel(name = "品种")
private String variety;
@@ -69,15 +67,136 @@ public class ScDryMilk extends BaseEntity
@Excel(name = "事件类型")
private String eventType;
/** 全部羊耳号列表(用于多耳号查询 */
private List<String> allEarNumbers;
/** 技术员多选列表 (新增用于MyBatis IN查询) */
private List<String> technicianList;
public List<String> getAllEarNumbers() {
return allEarNumbers;
public void setId(Long id)
{
this.id = id;
}
public void setAllEarNumbers(List<String> allEarNumbers) {
this.allEarNumbers = allEarNumbers;
public Long getId()
{
return id;
}
public void setSheepId(String sheepId)
{
this.sheepId = sheepId;
}
public String getSheepId()
{
return sheepId;
}
public void setDatetime(Date datetime)
{
this.datetime = datetime;
}
public Date getDatetime()
{
return datetime;
}
public void setStatus(Long status)
{
this.status = status;
}
public Long getStatus()
{
return status;
}
public void setSheepfold(Long sheepfold)
{
this.sheepfold = sheepfold;
}
public Long getSheepfold()
{
return sheepfold;
}
public void setTecahnician(String tecahnician)
{
this.tecahnician = tecahnician;
}
public String getTecahnician()
{
return tecahnician;
}
public void setComment(String comment)
{
this.comment = comment;
}
public String getComment()
{
return comment;
}
public String getManageTags() {
return manageTags;
}
public void setManageTags(String manageTags) {
this.manageTags = manageTags;
}
public List<String> getManageTagsList() {
return manageTagsList;
}
public void setManageTagsList(List<String> manageTagsList) {
this.manageTagsList = manageTagsList;
}
public String getVariety() {
return variety;
}
public void setVariety(String variety) {
this.variety = variety;
}
public String getSheepfoldName() {
return sheepfoldName;
}
public void setSheepfoldName(String sheepfoldName) {
this.sheepfoldName = sheepfoldName;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public List<String> getTechnicianList() {
return technicianList;
}
public void setTechnicianList(List<String> technicianList) {
this.technicianList = technicianList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("sheepId", getSheepId())
.append("datetime", getDatetime())
.append("status", getStatus())
.append("sheepfold", getSheepfold())
.append("tecahnician", getTecahnician())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("comment", getComment())
.append("manageTags", getManageTags())
.append("variety", getVariety())
.append("sheepfoldName", getSheepfoldName())
.toString();
}
}

View File

@@ -2,7 +2,6 @@ package com.zhyc.module.produce.breed.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -75,22 +74,28 @@ public class ScSheepDeath extends BaseEntity
/** 品种 */
private String variety;
/** 死亡时羊只类别 */
/** 羊只类型 (原事假类型改为羊只类型查询) */
@Excel(name = "羊只类型")
private String sheepType;
/** 性别 */
@Excel(name = "性别", readConverterExp = "1=母,2=公")
private Integer gender;
/** 日龄 */
@Excel(name = "日龄")
private Long dayAge;
/** 胎次 */
@Excel(name = "胎次")
private Integer parity;
/** 羊舍 */
@Excel(name = "羊舍")
private String sheepfoldName;
/** 繁育状态 */
@Excel(name = "繁育状态")
private String breedStatus;
/** 死亡时产后天数 */
@@ -102,236 +107,117 @@ public class ScSheepDeath extends BaseEntity
/** 死亡时怀孕天数 */
private Integer gestationDay;
public void setId(Long id)
{
this.id = id;
}
// 疾病名称
private String diseaseTypeName;
private String diseaseSubtypeName;
public Long getId()
{
return id;
}
// --- 多选查询条件 ---
public void setSheepId(Long sheepId)
{
this.sheepId = sheepId;
}
/** 多选管理耳号列表 */
private List<String> manageTagsList;
public Long getSheepId()
{
return sheepId;
}
/** 多选羊只类型列表 */
private List<String> sheepTypeList;
public void setManageTags(String manageTags)
{
this.manageTags = manageTags;
}
/** 多选技术员列表 */
private List<String> technicianList;
public String getManageTags()
{
return manageTags;
}
/** 多选处理人列表 */
private List<String> handlerList;
public void setEventType(String eventType)
{
this.eventType = eventType;
}
/** 多选班组列表 */
private List<String> workGroupList;
public String getEventType()
{
return eventType;
}
// Getter & Setter
public void setId(Long id) { this.id = id; }
public Long getId() { return id; }
public void setDeathDate(Date deathDate)
{
this.deathDate = deathDate;
}
public void setSheepId(Long sheepId) { this.sheepId = sheepId; }
public Long getSheepId() { return sheepId; }
public Date getDeathDate()
{
return deathDate;
}
public void setManageTags(String manageTags) { this.manageTags = manageTags; }
public String getManageTags() { return manageTags; }
public void setDiseaseTypeId(Long diseaseTypeId)
{
this.diseaseTypeId = diseaseTypeId;
}
public void setEventType(String eventType) { this.eventType = eventType; }
public String getEventType() { return eventType; }
public Long getDiseaseTypeId()
{
return diseaseTypeId;
}
public void setDeathDate(Date deathDate) { this.deathDate = deathDate; }
public Date getDeathDate() { return deathDate; }
public void setDiseaseSubtypeId(Long diseaseSubtypeId)
{
this.diseaseSubtypeId = diseaseSubtypeId;
}
public void setDiseaseTypeId(Long diseaseTypeId) { this.diseaseTypeId = diseaseTypeId; }
public Long getDiseaseTypeId() { return diseaseTypeId; }
public Long getDiseaseSubtypeId()
{
return diseaseSubtypeId;
}
public void setDiseaseSubtypeId(Long diseaseSubtypeId) { this.diseaseSubtypeId = diseaseSubtypeId; }
public Long getDiseaseSubtypeId() { return diseaseSubtypeId; }
public void setDisposalDirection(String disposalDirection)
{
this.disposalDirection = disposalDirection;
}
public void setDisposalDirection(String disposalDirection) { this.disposalDirection = disposalDirection; }
public String getDisposalDirection() { return disposalDirection; }
public String getDisposalDirection()
{
return disposalDirection;
}
public void setTechnician(String technician) { this.technician = technician; }
public String getTechnician() { return technician; }
public void setTechnician(String technician)
{
this.technician = technician;
}
public void setHandler(String handler) { this.handler = handler; }
public String getHandler() { return handler; }
public String getTechnician()
{
return technician;
}
public void setWorkGroup(String workGroup) { this.workGroup = workGroup; }
public String getWorkGroup() { return workGroup; }
public void setHandler(String handler)
{
this.handler = handler;
}
public void setComment(String comment) { this.comment = comment; }
public String getComment() { return comment; }
public String getHandler()
{
return handler;
}
public void setIsDelete(Long isDelete) { this.isDelete = isDelete; }
public Long getIsDelete() { return isDelete; }
public void setWorkGroup(String workGroup)
{
this.workGroup = workGroup;
}
public void setVariety(String variety) { this.variety = variety; }
public String getVariety() { return variety; }
public String getWorkGroup()
{
return workGroup;
}
public void setSheepType(String sheepType) { this.sheepType = sheepType; }
public String getSheepType() { return sheepType; }
public void setComment(String comment)
{
this.comment = comment;
}
public void setGender(Integer gender) { this.gender = gender; }
public Integer getGender() { return gender; }
public String getComment()
{
return comment;
}
public void setDayAge(Long dayAge) { this.dayAge = dayAge; }
public Long getDayAge() { return dayAge; }
public void setIsDelete(Long isDelete)
{
this.isDelete = isDelete;
}
public void setParity(Integer parity) { this.parity = parity; }
public Integer getParity() { return parity; }
public Long getIsDelete()
{
return isDelete;
}
public void setSheepfoldName(String sheepfoldName) { this.sheepfoldName = sheepfoldName; }
public String getSheepfoldName() { return sheepfoldName; }
// 以下为仅用于显示的字段的getter/setter
public void setVariety(String variety)
{
this.variety = variety;
}
public void setBreedStatus(String breedStatus) { this.breedStatus = breedStatus; }
public String getBreedStatus() { return breedStatus; }
public String getVariety()
{
return variety;
}
public void setPostLambingDay(Integer postLambingDay) { this.postLambingDay = postLambingDay; }
public Integer getPostLambingDay() { return postLambingDay; }
public void setSheepType(String sheepType)
{
this.sheepType = sheepType;
}
public void setLactationDay(Integer lactationDay) { this.lactationDay = lactationDay; }
public Integer getLactationDay() { return lactationDay; }
public String getSheepType()
{
return sheepType;
}
public void setGestationDay(Integer gestationDay) { this.gestationDay = gestationDay; }
public Integer getGestationDay() { return gestationDay; }
public void setGender(Integer gender)
{
this.gender = gender;
}
public String getDiseaseTypeName() { return diseaseTypeName; }
public void setDiseaseTypeName(String diseaseTypeName) { this.diseaseTypeName = diseaseTypeName; }
public Integer getGender()
{
return gender;
}
public String getDiseaseSubtypeName() { return diseaseSubtypeName; }
public void setDiseaseSubtypeName(String diseaseSubtypeName) { this.diseaseSubtypeName = diseaseSubtypeName; }
public void setDayAge(Long dayAge)
{
this.dayAge = dayAge;
}
public List<String> getManageTagsList() { return manageTagsList; }
public void setManageTagsList(List<String> manageTagsList) { this.manageTagsList = manageTagsList; }
public Long getDayAge()
{
return dayAge;
}
public List<String> getSheepTypeList() { return sheepTypeList; }
public void setSheepTypeList(List<String> sheepTypeList) { this.sheepTypeList = sheepTypeList; }
public void setParity(Integer parity)
{
this.parity = parity;
}
public List<String> getTechnicianList() { return technicianList; }
public void setTechnicianList(List<String> technicianList) { this.technicianList = technicianList; }
public Integer getParity()
{
return parity;
}
public List<String> getHandlerList() { return handlerList; }
public void setHandlerList(List<String> handlerList) { this.handlerList = handlerList; }
public void setSheepfoldName(String sheepfoldName)
{
this.sheepfoldName = sheepfoldName;
}
public String getSheepfoldName()
{
return sheepfoldName;
}
public void setBreedStatus(String breedStatus)
{
this.breedStatus = breedStatus;
}
public String getBreedStatus()
{
return breedStatus;
}
public void setPostLambingDay(Integer postLambingDay)
{
this.postLambingDay = postLambingDay;
}
public Integer getPostLambingDay()
{
return postLambingDay;
}
public void setLactationDay(Integer lactationDay)
{
this.lactationDay = lactationDay;
}
public Integer getLactationDay()
{
return lactationDay;
}
public void setGestationDay(Integer gestationDay)
{
this.gestationDay = gestationDay;
}
public Integer getGestationDay()
{
return gestationDay;
}
public List<String> getWorkGroupList() { return workGroupList; }
public void setWorkGroupList(List<String> workGroupList) { this.workGroupList = workGroupList; }
@Override
public String toString() {

View File

@@ -3,7 +3,6 @@ package com.zhyc.module.produce.breed.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
@@ -13,9 +12,6 @@ import lombok.NoArgsConstructor;
/**
* 断奶记录对象 sc_wean_record
*
* @author zhyc
* @date 2024-01-01
*/
@Data
@NoArgsConstructor
@@ -55,8 +51,19 @@ public class ScWeanRecord extends BaseEntity {
@Excel(name = "电子耳号")
private String electronicTags;
// 关联查询字段
/** 耳号 */
// --- 新增查询字段 ---
/** 多耳号查询列表 */
private List<String> allEarNumbers;
/** 是否在群 (1是 0否) */
private String isInHerd;
/** 羊只类别 (对应 sheep_file 的 breed 字段) */
private String sheepCategory;
// --- 关联查询显示字段 ---
@Excel(name = "耳号")
private String earNumber;
@@ -95,16 +102,4 @@ public class ScWeanRecord extends BaseEntity {
/** 繁育状态 */
@Excel(name = "繁育状态")
private String breedingStatus;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
public List<String> getAllEarNumbers() {
return allEarNumbers;
}
public void setAllEarNumbers(List<String> allEarNumbers) {
this.allEarNumbers = allEarNumbers;
}
}

View File

@@ -7,8 +7,7 @@ import org.apache.ibatis.annotations.Param;
/**
* 干奶记录Mapper接口
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
@Mapper
@@ -16,65 +15,58 @@ public interface ScDryMilkMapper
{
/**
* 查询干奶记录
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 干奶记录
*/
public ScDryMilk selectScDryMilkById(Long id);
/**
* 查询干奶记录列表
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 干奶记录集合
*/
public List<ScDryMilk> selectScDryMilkList(ScDryMilk scDryMilk);
/**
* 根据耳号查询羊只ID
*
* @param manageTags 管理耳号
* @return 羊只ID
*/
public Long selectSheepIdByManageTags(String manageTags);
/**
* 新增干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
public int insertScDryMilk(ScDryMilk scDryMilk);
/**
* 修改干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
public int updateScDryMilk(ScDryMilk scDryMilk);
/**
* 删除干奶记录
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 结果
*/
public int deleteScDryMilkById(Long id);
/**
* 批量删除干奶记录
*
* @param ids 需要删除的数据主键集合
* * @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScDryMilkByIds(Long[] ids);
public int deleteScDryMilkByIds(String[] ids);
/**
* 模糊查询母羊耳号列表
*
* @param query 查询关键字
* @return 耳号列表
* 根据耳号查询羊只ID
*/
List<String> searchEarNumbers(@Param("query") String query);
public Long selectSheepIdByManageTags(String manageTags);
/**
* 远程搜索耳号列表
*/
public List<String> selectSheepEarNumberList(@Param("query") String query);
/**
* 远程搜索技术员列表
*/
public List<String> searchTechnicianList(@Param("query") String query);
}

View File

@@ -2,8 +2,8 @@ package com.zhyc.module.produce.breed.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.zhyc.module.produce.breed.domain.ScSheepDeath;
import org.apache.ibatis.annotations.Param;
/**
* 羊只死淘记录Mapper接口
@@ -29,14 +29,6 @@ public interface ScSheepDeathMapper
*/
public List<ScSheepDeath> selectScSheepDeathList(ScSheepDeath scSheepDeath);
/**
* 根据管理耳号查询sheep_file视图信息
*
* @param manageTags 管理耳号
* @return 羊只信息
*/
public Map<String, Object> selectSheepFileByManageTags(String manageTags);
/**
* 新增羊只死淘记录
*
@@ -70,28 +62,27 @@ public interface ScSheepDeathMapper
public int deleteScSheepDeathByIds(Long[] ids);
/**
* 更新羊只繁育状态
*
* @param sheepId 羊只ID
* @param status 繁育状态
* @return 更新结果
* 根据管理耳号查询sheep_file视图信息
*/
public int updateSheepFileStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
public Map<String, Object> selectSheepFileByManageTags(@Param("manageTags") String manageTags);
/**
* 新增:更新羊只在群状态
*
* @param sheepId 羊只ID
* @param status 在群状态1-在群2-不在群)
* @return 更新结果
* 更新羊只在群状态
*/
public int updateSheepStatus(@Param("sheepId") Long sheepId, @Param("status") String status);
/**
* 模糊查询母羊耳号列表
*
* @param query 查询关键字
* @return 耳号列表
* 远程搜索:管理耳号
*/
List<String> searchEarNumbers(@Param("query") String query);
public List<String> selectDistinctManageTags(@Param("query") String query);
/**
* 远程搜索:技术员
*/
public List<String> selectDistinctTechnician(@Param("query") String query);
/**
* 远程搜索:处理人
*/
public List<String> selectDistinctHandler(@Param("query") String query);
}

View File

@@ -2,86 +2,75 @@ package com.zhyc.module.produce.breed.mapper;
import java.util.List;
import com.zhyc.module.produce.breed.domain.ScWeanRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 断奶记录Mapper接口
*
* @author zhyc
* * @author zhyc
* @date 2024-01-01
*/
@Mapper
public interface ScWeanRecordMapper {
public interface ScWeanRecordMapper
{
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 断奶记录
*/
public ScWeanRecord selectScWeanRecordById(Long id);
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 断奶记录集合
*/
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord);
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
public int insertScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
public int updateScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 删除断奶记录
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 结果
*/
public int deleteScWeanRecordById(Long id);
/**
* 批量删除断奶记录
*
* @param ids 需要删除的数据主键集合
* * @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteScWeanRecordByIds(Long[] ids);
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
public Long selectSheepIdByEarNumber(String earNumber);
/**
* 根据耳号更新bas_sheep表中的断奶信息
*
* @param scWeanRecord 断奶记录
* 更新基础羊只表的断奶信息 (对应XML中的updateBasSheepWeaningInfo)
* @param scWeanRecord 断奶信息
* @return 结果
*/
public int updateBasSheepWeaningInfo(ScWeanRecord scWeanRecord);
/**
* 模糊查询母羊耳号列表
*
* 【新增】模糊查询耳号列表 (用于前端远程搜索)
* @param query 查询关键字
* @return 耳号列表
*/
List<String> searchEarNumbers(@Param("query") String query);
public List<String> searchEarNumbers(@Param("query") String query);
}

View File

@@ -5,67 +5,65 @@ import com.zhyc.module.produce.breed.domain.ScDryMilk;
/**
* 干奶记录Service接口
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
public interface IScDryMilkService
public interface IScDryMilkService
{
/**
* 查询干奶记录
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 干奶记录
*/
public ScDryMilk selectScDryMilkById(Long id);
/**
* 查询干奶记录列表
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 干奶记录集合
*/
public List<ScDryMilk> selectScDryMilkList(ScDryMilk scDryMilk);
Long selectSheepIdByManageTags(String manageTags);
/**
* 新增干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
public int insertScDryMilk(ScDryMilk scDryMilk);
/**
* 修改干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
public int updateScDryMilk(ScDryMilk scDryMilk);
/**
* 批量删除干奶记录
*
* @param ids 需要删除的干奶记录主键集合
* * @param ids 需要删除的干奶记录主键集合
* @return 结果
*/
public int deleteScDryMilkByIds(Long[] ids);
/**
* 删除干奶记录信息
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 结果
*/
public int deleteScDryMilkById(Long id);
/**
* 模糊查询母羊耳号列表
*
* @param query 查询关键字
* @return 耳号列表
* 根据耳号查询羊只ID
*/
public List<String> searchEarNumbers(String query);
}
public Long selectSheepIdByManageTags(String manageTags);
/**
* 远程搜索耳号列表
*/
public List<String> selectSheepEarNumberList(String query);
/**
* 远程搜索技术员列表
*/
public List<String> selectTechnicianList(String query);
}

View File

@@ -28,14 +28,6 @@ public interface IScSheepDeathService
*/
public List<ScSheepDeath> selectScSheepDeathList(ScSheepDeath scSheepDeath);
/**
* 根据管理耳号查询sheep_file视图信息
*
* @param manageTags 管理耳号
* @return 羊只信息
*/
public Map<String, Object> selectSheepFileByManageTags(String manageTags);
/**
* 新增羊只死淘记录
*
@@ -69,10 +61,25 @@ public interface IScSheepDeathService
public int deleteScSheepDeathById(Long id);
/**
* 模糊查询母羊耳号列表
* 根据管理耳号查询sheep_file视图信息
*
* @param query 查询关键字
* @return 耳号列表
* @param manageTags 管理耳号
* @return 羊只信息
*/
public List<String> searchEarNumbers(String query);
public Map<String, Object> selectSheepFileByManageTags(String manageTags);
/**
* 远程搜索:管理耳号
*/
public List<String> selectDistinctManageTags(String query);
/**
* 远程搜索:技术员
*/
public List<String> selectDistinctTechnician(String query);
/**
* 远程搜索:处理人
*/
public List<String> selectDistinctHandler(String query);
}

View File

@@ -6,70 +6,62 @@ import com.zhyc.module.produce.breed.domain.ScWeanRecord;
/**
* 断奶记录Service接口
*
* @author ruoyi
* @date 2025-07-13
* * @author zhyc
* @date 2024-01-01
*/
public interface IScWeanRecordService {
public interface IScWeanRecordService
{
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 断奶记录
*/
public ScWeanRecord selectScWeanRecordById(Long id);
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 断奶记录集合
*/
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord);
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
public int insertScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
public int updateScWeanRecord(ScWeanRecord scWeanRecord);
/**
* 批量删除断奶记录
*
* @param ids 需要删除的断奶记录主键集合
* * @param ids 需要删除的断奶记录主键集合
* @return 结果
*/
public int deleteScWeanRecordByIds(Long[] ids);
/**
* 删除断奶记录信息
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 结果
*/
public int deleteScWeanRecordById(Long id);
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
public Long selectSheepIdByEarNumber(String earNumber);
/**
* 模糊查询母羊耳号列表
*
* 【新增】模糊查询耳号列表
* @param query 查询关键字
* @return 耳号列表
*/

View File

@@ -1,20 +1,16 @@
package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import java.util.Date;
import com.zhyc.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.breed.mapper.ScDryMilkMapper;
import com.zhyc.module.produce.breed.domain.ScDryMilk;
import com.zhyc.module.produce.breed.service.IScDryMilkService;
import com.zhyc.common.utils.StringUtils;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.exception.ServiceException;
/**
* 干奶记录Service业务层处理
*
* @author ruoyi
* * @author ruoyi
* @date 2025-07-15
*/
@Service
@@ -25,8 +21,7 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
/**
* 查询干奶记录
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 干奶记录
*/
@Override
@@ -37,8 +32,7 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
/**
* 查询干奶记录列表
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 干奶记录
*/
@Override
@@ -47,90 +41,47 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
return scDryMilkMapper.selectScDryMilkList(scDryMilk);
}
/**
* 根据耳号查询羊只ID
*
* @param manageTags 管理耳号
* @return 羊只ID
*/
@Override
public Long selectSheepIdByManageTags(String manageTags)
{
return scDryMilkMapper.selectSheepIdByManageTags(manageTags);
}
/**
* 新增干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
@Override
public int insertScDryMilk(ScDryMilk scDryMilk)
{
// 如果传入的是耳号需要转换为羊只ID
if (StringUtils.isNotEmpty(scDryMilk.getManageTags()) && StringUtils.isEmpty(scDryMilk.getSheepId()))
{
Long sheepId = scDryMilkMapper.selectSheepIdByManageTags(scDryMilk.getManageTags());
if (sheepId == null)
{
throw new ServiceException("未找到对应耳号的羊只信息");
}
scDryMilk.setSheepId(String.valueOf(sheepId));
}
// 自动设置创建时间(精确到分钟)
scDryMilk.setCreateTime(DateUtils.getNowDate());
// 如果有获取当前用户的方法,可以设置创建人
// scDryMilk.setCreateBy(SecurityUtils.getUsername());
return scDryMilkMapper.insertScDryMilk(scDryMilk);
}
/**
* 修改干奶记录
*
* @param scDryMilk 干奶记录
* * @param scDryMilk 干奶记录
* @return 结果
*/
@Override
public int updateScDryMilk(ScDryMilk scDryMilk)
{
// 如果传入的是耳号需要转换为羊只ID
if (StringUtils.isNotEmpty(scDryMilk.getManageTags()) && StringUtils.isEmpty(scDryMilk.getSheepId()))
{
Long sheepId = scDryMilkMapper.selectSheepIdByManageTags(scDryMilk.getManageTags());
if (sheepId == null)
{
throw new ServiceException("未找到对应耳号的羊只信息");
}
scDryMilk.setSheepId(String.valueOf(sheepId));
}
// 设置更新时间
scDryMilk.setUpdateTime(DateUtils.getNowDate());
// 如果有获取当前用户的方法,可以设置更新人
// scDryMilk.setUpdateBy(SecurityUtils.getUsername());
return scDryMilkMapper.updateScDryMilk(scDryMilk);
}
/**
* 批量删除干奶记录
*
* @param ids 需要删除的干奶记录主键
* * @param ids 需要删除的干奶记录主键
* @return 结果
*/
@Override
public int deleteScDryMilkByIds(Long[] ids)
{
return scDryMilkMapper.deleteScDryMilkByIds(ids);
String[] strIds = new String[ids.length];
for(int i=0; i<ids.length; i++){
strIds[i] = String.valueOf(ids[i]);
}
return scDryMilkMapper.deleteScDryMilkByIds(strIds);
}
/**
* 删除干奶记录信息
*
* @param id 干奶记录主键
* * @param id 干奶记录主键
* @return 结果
*/
@Override
@@ -139,11 +90,18 @@ public class ScDryMilkServiceImpl implements IScDryMilkService
return scDryMilkMapper.deleteScDryMilkById(id);
}
// ScLambingRecordServiceImpl.java 添加方法
@Override
public List<String> searchEarNumbers(String query) {
return scDryMilkMapper.searchEarNumbers(query);
public Long selectSheepIdByManageTags(String manageTags) {
return scDryMilkMapper.selectSheepIdByManageTags(manageTags);
}
@Override
public List<String> selectSheepEarNumberList(String query) {
return scDryMilkMapper.selectSheepEarNumberList(query);
}
@Override
public List<String> selectTechnicianList(String query) {
return scDryMilkMapper.searchTechnicianList(query);
}
}

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import java.util.Map;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.bean.BeanUtils;
import com.zhyc.module.biosafety.domain.Diagnosis;
import com.zhyc.module.biosafety.domain.Treatment;
import com.zhyc.module.biosafety.mapper.DiagnosisMapper;
@@ -31,123 +32,69 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
@Autowired
private TreatmentServiceImpl treatmentService;
/**
* 查询羊只死淘记录
*
* @param id 羊只死淘记录主键
* @return 羊只死淘记录
*/
@Override
public ScSheepDeath selectScSheepDeathById(Long id)
{
ScSheepDeath scSheepDeath = scSheepDeathMapper.selectScSheepDeathById(id);
// 查询时也需要填充显示字段
if (scSheepDeath != null && scSheepDeath.getManageTags() != null) {
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
if (sheepInfo != null) {
scSheepDeath.setVariety(sheepInfo.get("variety") != null ? sheepInfo.get("variety").toString() : null);
scSheepDeath.setSheepType(sheepInfo.get("sheepType") != null ? sheepInfo.get("sheepType").toString() : null);
scSheepDeath.setGender(sheepInfo.get("gender") != null ? Integer.valueOf(sheepInfo.get("gender").toString()) : null);
scSheepDeath.setDayAge(sheepInfo.get("dayAge") != null ? Long.valueOf(sheepInfo.get("dayAge").toString()) : null);
scSheepDeath.setParity(sheepInfo.get("parity") != null ? Integer.valueOf(sheepInfo.get("parity").toString()) : null);
scSheepDeath.setSheepfoldName(sheepInfo.get("sheepfoldName") != null ? sheepInfo.get("sheepfoldName").toString() : null);
scSheepDeath.setBreedStatus(sheepInfo.get("breedStatus") != null ? sheepInfo.get("breedStatus").toString() : null);
scSheepDeath.setPostLambingDay(sheepInfo.get("postLambingDay") != null ? Integer.valueOf(sheepInfo.get("postLambingDay").toString()) : null);
scSheepDeath.setLactationDay(sheepInfo.get("lactationDay") != null ? Integer.valueOf(sheepInfo.get("lactationDay").toString()) : null);
scSheepDeath.setGestationDay(sheepInfo.get("gestationDay") != null ? Integer.valueOf(sheepInfo.get("gestationDay").toString()) : null);
}
}
return scSheepDeath;
return scSheepDeathMapper.selectScSheepDeathById(id);
}
/**
* 查询羊只死淘记录列表
*
* @param scSheepDeath 羊只死淘记录
* @return 羊只死淘记录
*/
@Override
public List<ScSheepDeath> selectScSheepDeathList(ScSheepDeath scSheepDeath)
{
List<ScSheepDeath> list = scSheepDeathMapper.selectScSheepDeathList(scSheepDeath);
// 为列表中的每条记录填充显示字段
for (ScSheepDeath death : list) {
if (death.getManageTags() != null) {
Map<String, Object> sheepInfo = selectSheepFileByManageTags(death.getManageTags());
if (sheepInfo != null) {
death.setVariety(sheepInfo.get("variety") != null ? sheepInfo.get("variety").toString() : null);
death.setSheepType(sheepInfo.get("sheepType") != null ? sheepInfo.get("sheepType").toString() : null);
death.setGender(sheepInfo.get("gender") != null ? Integer.valueOf(sheepInfo.get("gender").toString()) : null);
death.setDayAge(sheepInfo.get("dayAge") != null ? Long.valueOf(sheepInfo.get("dayAge").toString()) : null);
death.setParity(sheepInfo.get("parity") != null ? Integer.valueOf(sheepInfo.get("parity").toString()) : null);
death.setSheepfoldName(sheepInfo.get("sheepfoldName") != null ? sheepInfo.get("sheepfoldName").toString() : null);
death.setBreedStatus(sheepInfo.get("breedStatus") != null ? sheepInfo.get("breedStatus").toString() : null);
death.setPostLambingDay(sheepInfo.get("postLambingDay") != null ? Integer.valueOf(sheepInfo.get("postLambingDay").toString()) : null);
death.setLactationDay(sheepInfo.get("lactationDay") != null ? Integer.valueOf(sheepInfo.get("lactationDay").toString()) : null);
death.setGestationDay(sheepInfo.get("gestationDay") != null ? Integer.valueOf(sheepInfo.get("gestationDay").toString()) : null);
}
}
}
return list;
return scSheepDeathMapper.selectScSheepDeathList(scSheepDeath);
}
/**
* 根据管理耳号查询sheep_file视图信息
*
* @param manageTags 管理耳号
* @return 羊只信息
*/
@Override
public Map<String, Object> selectSheepFileByManageTags(String manageTags)
{
return scSheepDeathMapper.selectSheepFileByManageTags(manageTags);
}
/**
* 新增羊只死淘记录
*
* @param scSheepDeath 羊只死淘记录
* @return 结果
*/
@Override
@Transactional
public int insertScSheepDeath(ScSheepDeath scSheepDeath)
{
// 设置事件类型默认为"死亡"
if (scSheepDeath.getEventType() == null || scSheepDeath.getEventType().isEmpty()) {
scSheepDeath.setEventType("死亡");
String manageTagsInput = scSheepDeath.getManageTags();
if (manageTagsInput == null || manageTagsInput.trim().isEmpty()) {
return 0;
}
// 如果有管理耳号查询并设置羊只ID
if (scSheepDeath.getManageTags() != null && !scSheepDeath.getManageTags().isEmpty()) {
Map<String, Object> sheepInfo = selectSheepFileByManageTags(scSheepDeath.getManageTags());
// 支持空格、逗号分隔
String[] tags = manageTagsInput.split("[\\s,]+");
int successCount = 0;
for (String tag : tags) {
if (tag == null || tag.trim().isEmpty()) {
continue;
}
ScSheepDeath newRecord = new ScSheepDeath();
BeanUtils.copyProperties(scSheepDeath, newRecord);
newRecord.setManageTags(tag.trim());
newRecord.setId(null);
if (newRecord.getEventType() == null || newRecord.getEventType().isEmpty()) {
newRecord.setEventType("死亡");
}
Map<String, Object> sheepInfo = selectSheepFileByManageTags(newRecord.getManageTags());
if (sheepInfo != null) {
Long sheepId = sheepInfo.get("sheepId") != null ? Long.valueOf(sheepInfo.get("sheepId").toString()) : null;
scSheepDeath.setSheepId(sheepId);
newRecord.setSheepId(sheepId);
// 插入死淘记录后,同时更新羊只在群状态为"不在群"状态ID为2
if (sheepId != null) {
scSheepDeathMapper.updateSheepStatus(sheepId, "2");
treatmentService.updateTreatmentStatus(sheepId);
}
}
newRecord.setCreateTime(DateUtils.getNowDate());
successCount += scSheepDeathMapper.insertScSheepDeath(newRecord);
}
treatmentService.updateTreatmentStatus(scSheepDeath.getSheepId());
scSheepDeath.setCreateTime(DateUtils.getNowDate());
return scSheepDeathMapper.insertScSheepDeath(scSheepDeath);
return successCount;
}
/**
* 修改羊只死淘记录
*
* @param scSheepDeath 羊只死淘记录
* @return 结果
*/
@Override
public int updateScSheepDeath(ScSheepDeath scSheepDeath)
{
@@ -168,12 +115,6 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
return scSheepDeathMapper.updateScSheepDeath(scSheepDeath);
}
/**
* 批量删除羊只死淘记录
*
* @param ids 需要删除的羊只死淘记录主键
* @return 结果
*/
@Override
public int deleteScSheepDeathByIds(Long[] ids)
{
@@ -189,12 +130,6 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
return scSheepDeathMapper.deleteScSheepDeathByIds(ids);
}
/**
* 删除羊只死淘记录信息
*
* @param id 羊只死淘记录主键
* @return 结果
*/
@Override
public int deleteScSheepDeathById(Long id)
{
@@ -208,8 +143,19 @@ public class ScSheepDeathServiceImpl implements IScSheepDeathService
return scSheepDeathMapper.deleteScSheepDeathById(id);
}
// --- 远程搜索实现 ---
@Override
public List<String> searchEarNumbers(String query) {
return scSheepDeathMapper.searchEarNumbers(query);
public List<String> selectDistinctManageTags(String query) {
return scSheepDeathMapper.selectDistinctManageTags(query);
}
@Override
public List<String> selectDistinctTechnician(String query) {
return scSheepDeathMapper.selectDistinctTechnician(query);
}
@Override
public List<String> selectDistinctHandler(String query) {
return scSheepDeathMapper.selectDistinctHandler(query);
}
}

View File

@@ -2,8 +2,10 @@ package com.zhyc.module.produce.breed.service.impl;
import java.util.List;
import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.produce.breed.domain.ScWeanRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhyc.module.produce.breed.mapper.ScWeanRecordMapper;
import com.zhyc.module.produce.breed.domain.ScWeanRecord;
import com.zhyc.module.produce.breed.service.IScWeanRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -11,127 +13,112 @@ import org.springframework.transaction.annotation.Transactional;
/**
* 断奶记录Service业务层处理
*
* @author ruoyi
* @date 2025-07-13
* * @author zhyc
* @date 2024-01-01
*/
@Service
public class ScWeanRecordServiceImpl implements IScWeanRecordService {
public class ScWeanRecordServiceImpl implements IScWeanRecordService
{
@Autowired
private ScWeanRecordMapper scWeanRecordMapper;
/**
* 查询断奶记录
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 断奶记录
*/
@Override
public ScWeanRecord selectScWeanRecordById(Long id) {
public ScWeanRecord selectScWeanRecordById(Long id)
{
return scWeanRecordMapper.selectScWeanRecordById(id);
}
/**
* 查询断奶记录列表
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 断奶记录
*/
@Override
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord) {
public List<ScWeanRecord> selectScWeanRecordList(ScWeanRecord scWeanRecord)
{
return scWeanRecordMapper.selectScWeanRecordList(scWeanRecord);
}
/**
* 新增断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
@Override
@Transactional
public int insertScWeanRecord(ScWeanRecord scWeanRecord) {
// 如果前端传递的是耳号需要先获取羊只ID
if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) {
Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId != null) {
scWeanRecord.setSheepId(sheepId);
}
}
public int insertScWeanRecord(ScWeanRecord scWeanRecord)
{
scWeanRecord.setCreateTime(DateUtils.getNowDate());
// 1. 插入断奶记录
int rows = scWeanRecordMapper.insertScWeanRecord(scWeanRecord);
// 插入断奶记录
int result = scWeanRecordMapper.insertScWeanRecord(scWeanRecord);
// 同步更新bas_sheep表中的断奶信息
if (result > 0 && scWeanRecord.getEarNumber() != null) {
// 2. 同步更新羊只档案中的断奶状态(断奶日期、断奶重、电子耳号等)
// 确保 scWeanRecord 中包含 earNumber (Controller中add方法校验过)
if (rows > 0 && scWeanRecord.getEarNumber() != null) {
scWeanRecordMapper.updateBasSheepWeaningInfo(scWeanRecord);
}
return result;
return rows;
}
/**
* 修改断奶记录
*
* @param scWeanRecord 断奶记录
* * @param scWeanRecord 断奶记录
* @return 结果
*/
@Override
@Transactional
public int updateScWeanRecord(ScWeanRecord scWeanRecord) {
// 如果前端传递的是耳号需要先获取羊只ID
if (scWeanRecord.getEarNumber() != null && scWeanRecord.getSheepId() == null) {
Long sheepId = scWeanRecordMapper.selectSheepIdByEarNumber(scWeanRecord.getEarNumber());
if (sheepId != null) {
scWeanRecord.setSheepId(sheepId);
}
}
public int updateScWeanRecord(ScWeanRecord scWeanRecord)
{
// 1. 更新断奶记录
int rows = scWeanRecordMapper.updateScWeanRecord(scWeanRecord);
// 更新断奶记录
int result = scWeanRecordMapper.updateScWeanRecord(scWeanRecord);
// 同步更新bas_sheep表中的断奶信息
if (result > 0 && scWeanRecord.getEarNumber() != null) {
// 2. 同步更新羊只档案信息
if (rows > 0 && scWeanRecord.getEarNumber() != null) {
scWeanRecordMapper.updateBasSheepWeaningInfo(scWeanRecord);
}
return result;
return rows;
}
/**
* 批量删除断奶记录
*
* @param ids 需要删除的断奶记录主键
* * @param ids 需要删除的断奶记录主键
* @return 结果
*/
@Override
public int deleteScWeanRecordByIds(Long[] ids) {
public int deleteScWeanRecordByIds(Long[] ids)
{
return scWeanRecordMapper.deleteScWeanRecordByIds(ids);
}
/**
* 删除断奶记录信息
*
* @param id 断奶记录主键
* * @param id 断奶记录主键
* @return 结果
*/
@Override
public int deleteScWeanRecordById(Long id) {
public int deleteScWeanRecordById(Long id)
{
return scWeanRecordMapper.deleteScWeanRecordById(id);
}
/**
* 根据耳号查询羊只ID
*
* @param earNumber 耳号
* @return 羊只ID
*/
@Override
public Long selectSheepIdByEarNumber(String earNumber) {
return scWeanRecordMapper.selectSheepIdByEarNumber(earNumber);
}
/**
* 【新增】模糊查询耳号列表 (用于前端远程搜索)
* @param query 查询关键字
* @return 耳号列表
*/
@Override
public List<String> searchEarNumbers(String query) {
return scWeanRecordMapper.searchEarNumbers(query);

View File

@@ -31,7 +31,7 @@
bacterial_colony_1, bacterial_colony_2, bacterial_colony_3,
bacterial_colony_4, bacterial_colony_5, coli, lactoferrin,
ig, commnet, create_by, create_time
FROM np_fresh_milk_insp
FROM np_fresh_milk_insp a
</sql>
<select id="selectNpFreshMilkInspList" parameterType="NpFreshMilkInsp" resultMap="NpFreshMilkInspResult">
@@ -46,6 +46,8 @@
<if test="params.endTime != null and params.endTime != ''">
AND datetime &lt;= #{params.endTime}
</if>
${params.dataScope}
</where>
</select>
@@ -74,6 +76,8 @@
<if test="commnet != null">commnet,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="source != null">#{source},</if>
@@ -93,6 +97,8 @@
<if test="commnet != null">#{commnet},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.dairyProducts.mapper.NpMilkInOutStoreMapper">
<select id="selectWithColumns" resultType="map">
SELECT s.datetime, s.num, s.colost_sheep, s.commercial_intake, s.anti_intake,
@@ -20,6 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="start != null"> s.datetime &gt;= #{start}</if>
<if test="end != null"> AND s.datetime &lt;= #{end}</if>
${params.dataScope}
</where>
GROUP BY s.id
ORDER BY s.datetime
@@ -32,27 +34,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INSERT INTO np_milk_in_out_store(datetime, num, colost_sheep, commercial_intake, anti_intake,
colost_intake, intake_total, commercial_test, colost_test, transfer_commercial,
transfer_anti, transfer_colost, transfer_total, loss, stock_commercial,
stock_anti, colost, return_fresh, return_yogurt)
stock_anti, colost, return_fresh, return_yogurt, user_id, dept_id)
VALUES (
#{datetime}, #{num}, #{colostSheep}, #{commercialIntake}, #{antiIntake},
#{colostIntake}, #{intakeTotal}, #{commercialTest}, #{colostTest},
#{transferCommercial}, #{transferAnti}, #{transferColost}, #{transferTotal},
#{loss}, #{stockCommercial}, #{stockAnti}, #{colost}, #{returnFresh}, #{returnYogurt}
#{loss}, #{stockCommercial}, #{stockAnti}, #{colost}, #{returnFresh}, #{returnYogurt}, #{userId}, #{deptId}
)
</insert>
<insert id="insertFeedRecord">
INSERT INTO np_milk_feed_records(store_id, source_id, amount)
INSERT INTO np_milk_feed_records(store_id, source_id, amount, user_id, dept_id)
VALUES(#{storeId},
(SELECT id FROM np_milk_feed WHERE source_name = #{source}),
#{amount})
#{amount}, #{userId}, #{deptId})
</insert>
<insert id="insertSaleRecord">
INSERT INTO np_milk_sale_records(store_id, destination_id, amount)
INSERT INTO np_milk_sale_records(store_id, destination_id, amount, user_id, dept_id)
VALUES(#{storeId},
(SELECT id FROM np_milk_sale WHERE destination_name = #{destination}),
#{amount})
#{amount}, #{userId}, #{deptId})
</insert>
</mapper>
</mapper>

View File

@@ -54,6 +54,8 @@
<if test="npMilkProdClasses.classes != null">
AND mpc.classes = #{npMilkProdClasses.classes}
</if>
${npMilkProdClasses.params.dataScope}
</where>
</select>
@@ -93,8 +95,8 @@
</select>
<insert id="insertNpMilkProdClasses" useGeneratedKeys="true" keyProperty="id">
INSERT INTO np_milk_prod_classes (datetime, sheep_id, classes, milk, corrected_milk)
VALUES (#{datetime}, #{sheepId}, #{classes}, #{milk}, #{correctedMilk})
INSERT INTO np_milk_prod_classes (datetime, sheep_id, classes, milk, corrected_milk, user_id, dept_id)
VALUES (#{datetime}, #{sheepId}, #{classes}, #{milk}, #{correctedMilk}, #{userId}, #{deptId})
</insert>
<select id="selectSheepIdByManageEarNo" resultType="java.lang.String">

View File

@@ -34,7 +34,7 @@
select id, datetime, source, freeze, density, fat, protein, non_fat, dry_matter,
impurity, lactose, ash_content, acidity, ph, bacterial_colony, lactoferrin,
ig, somatic_cell, usea, fat_ratio, comment, create_by, create_time
from np_raw_milk_inspe
from np_raw_milk_inspe a
</sql>
<select id="selectNpRawMilkInspeList" parameterType="NpRawMilkInspe" resultMap="NpRawMilkInspeResult">
@@ -47,6 +47,8 @@
and datetime &lt;= #{params.endTime}
</if>
<if test="source != null and source != ''"> and source like concat('%', #{source}, '%')</if>
${params.dataScope}
</where>
</select>
@@ -80,6 +82,8 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="datetime != null">#{datetime},</if>
@@ -104,6 +108,8 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>

View File

@@ -30,7 +30,7 @@
acidity, bacterial_colony_1, bacterial_clony_2,
bacterial_clony_3, bacterial_clony_4, bacterial_clony_5,
yeast, mould, lacto, comment, create_by, create_time
from np_yogurt_insp
from np_yogurt_insp a
</sql>
<select id="selectNpYogurtInspList" parameterType="NpYogurtInsp" resultMap="NpYogurtInspResult">
@@ -45,6 +45,8 @@
<if test="params.endTime != null and params.endTime != ''">
and datetime &lt;= #{params.endTime}
</if>
${params.dataScope}
</where>
</select>
@@ -73,6 +75,8 @@
<if test="comment != null">comment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="source != null">#{source},</if>
@@ -92,6 +96,8 @@
<if test="comment != null">#{comment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@@ -105,7 +111,7 @@
<if test="nonFat != null">non_fat = #{nonFat},</if>
<if test="acidity != null">acidity = #{acidity},</if>
<if test="bacterialColony1 != null">bacterial_colony_1 = #{bacterialColony1},</if>
<if test="bacterialClony2 != null">bacterial_clony_2 = #{bacterialClony2},</if>
<if test="bacterialClony2 != null">bacterial_colony_2 = #{bacterialClony2},</if>
<if test="bacterialClony3 != null">bacterial_clony_3 = #{bacterialClony3},</if>
<if test="bacterialClony4 != null">bacterial_clony_4 = #{bacterialClony4},</if>
<if test="bacterialClony5 != null">bacterial_clony_5 = #{bacterialClony5},</if>

View File

@@ -11,51 +11,56 @@
<result property="content" column="content"/>
<result property="standard" column="standard"/>
<result property="coefficient" column="coefficient"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectXzDryMatterCorrectionVo">
SELECT
id,
datetime,
factory,
content,
COALESCE(standard, 18) as standard,
d.id,
d.datetime,
d.factory,
d.content,
COALESCE(d.standard, 18) as standard,
CASE
WHEN standard = 0 OR standard IS NULL THEN NULL
ELSE ROUND(content / standard, 2)
END AS coefficient
FROM xz_dry_matter_correction
WHEN d.standard = 0 OR d.standard IS NULL THEN NULL
ELSE ROUND(d.content / d.standard, 2)
END AS coefficient,
d.user_id,
d.dept_id
FROM xz_dry_matter_correction d
</sql>
<select id="selectXzDryMatterCorrectionList" parameterType="XzDryMatterCorrection" resultMap="XzDryMatterCorrectionResult">
<include refid="selectXzDryMatterCorrectionVo"/>
<where>
<if test="params.beginTime != null and params.beginTime != ''">
AND DATE_FORMAT(datetime, '%Y-%m') &gt;= #{params.beginTime}
AND DATE_FORMAT(d.datetime, '%Y-%m') &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''">
AND DATE_FORMAT(datetime, '%Y-%m') &lt;= #{params.endTime}
AND DATE_FORMAT(d.datetime, '%Y-%m') &lt;= #{params.endTime}
</if>
<if test="factory != null and factory != ''">
AND factory = #{factory}
AND d.factory = #{factory}
</if>
AND (standard IS NULL OR standard != 0)
AND (d.standard IS NULL OR d.standard != 0)
${params.dataScope}
</where>
ORDER BY datetime DESC
ORDER BY d.datetime DESC
</select>
<select id="selectXzDryMatterCorrectionById" parameterType="Long" resultMap="XzDryMatterCorrectionResult">
<include refid="selectXzDryMatterCorrectionVo"/>
WHERE id = #{id}
WHERE d.id = #{id}
</select>
<insert id="insertXzDryMatterCorrection" parameterType="XzDryMatterCorrection" useGeneratedKeys="true" keyProperty="id">
INSERT INTO xz_dry_matter_correction
<trim prefix="(" suffix=")" suffixOverrides=",">
datetime, factory, content, standard
datetime, factory, content, standard, user_id, dept_id
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{datetime}, #{factory}, #{content}, #{standard}
#{datetime}, #{factory}, #{content}, #{standard}, #{userId}, #{deptId}
</trim>
</insert>

View File

@@ -11,38 +11,44 @@
<result property="actual" column="actual" />
<result property="systemMilk" column="system_milk" />
<result property="coefficient" column="coefficient" />
<result property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
</resultMap>
<sql id="selectXzWegihCorrectionVo">
select
id,
datetime,
factory,
actual,
system_milk,
w.id,
w.datetime,
w.factory,
w.actual,
w.system_milk,
CASE
WHEN system_milk = 0 THEN 0
ELSE ROUND(actual / system_milk, 4)
END as coefficient
from xz_wegih_correction
WHEN w.system_milk = 0 THEN 0
ELSE ROUND(w.actual / w.system_milk, 4)
END as coefficient,
w.user_id,
w.dept_id
from xz_wegih_correction w
</sql>
<select id="selectXzWegihCorrectionList" parameterType="XzWegihCorrection" resultMap="XzWegihCorrectionResult">
<include refid="selectXzWegihCorrectionVo"/>
<where>
<if test="params.beginTime != null and params.beginTime != ''">
and datetime &gt;= #{params.beginTime}
and w.datetime &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''">
and datetime &lt;= #{params.endTime}
and w.datetime &lt;= #{params.endTime}
</if>
<if test="factory != null and factory != ''"> and factory = #{factory}</if>
<if test="factory != null and factory != ''"> and w.factory = #{factory}</if>
${params.dataScope}
</where>
</select>
<select id="selectXzWegihCorrectionById" parameterType="Long" resultMap="XzWegihCorrectionResult">
<include refid="selectXzWegihCorrectionVo"/>
where id = #{id}
where w.id = #{id}
</select>
<insert id="insertXzWegihCorrection" parameterType="XzWegihCorrection" useGeneratedKeys="true" keyProperty="id">
@@ -52,12 +58,14 @@
<if test="factory != null">factory,</if>
<if test="actual != null">actual,</if>
<if test="systemMilk != null">system_milk,</if>
user_id, dept_id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="datetime != null">#{datetime},</if>
<if test="factory != null">#{factory},</if>
<if test="actual != null">#{actual},</if>
<if test="systemMilk != null">#{systemMilk},</if>
#{userId}, #{deptId}
</trim>
</insert>

View File

@@ -33,34 +33,53 @@
<select id="selectScDryMilkList" parameterType="ScDryMilk" resultMap="ScDryMilkResult">
<include refid="selectScDryMilkVo"/>
<where>
<!-- 多耳号精确匹配查询 -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
<if test="manageTagsList != null and manageTagsList.size() > 0">
AND s.bs_manage_tags IN
<foreach item="earNumber" collection="allEarNumbers" open="(" separator="," close=")">
#{earNumber}
<foreach collection="manageTagsList" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
</if>
<!-- 保留原单耳号模糊查询(仅当allEarNumbers为空时生效) -->
<if test="(allEarNumbers == null or allEarNumbers.size() == 0) and manageTags != null and manageTags != ''">
AND s.bs_manage_tags LIKE CONCAT('%', #{manageTags}, '%')
<if test="(manageTagsList == null or manageTagsList.size() == 0) and manageTags != null and manageTags != ''">
AND s.bs_manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="sheepId != null">AND d.sheep_id = #{sheepId}</if>
<if test="datetime != null">AND d.datetime = #{datetime}</if>
<if test="status != null">AND d.status = #{status}</if>
<if test="sheepfold != null">AND d.sheepfold = #{sheepfold}</if>
<if test="tecahnician != null and tecahnician != ''">
AND d.tecahnician LIKE CONCAT('%', #{tecahnician}, '%')
<if test="technicianList != null and technicianList.size() > 0">
AND d.tecahnician IN
<foreach collection="technicianList" item="tech" open="(" separator="," close=")">
#{tech}
</foreach>
</if>
<if test="createBy != null and createBy != ''">AND d.create_by = #{createBy}</if>
<if test="createTime != null">AND d.create_time = #{createTime}</if>
<if test="variety != null and variety != ''">
AND s.variety LIKE CONCAT('%', #{variety}, '%')
<if test="(technicianList == null or technicianList.size() == 0) and tecahnician != null and tecahnician != ''">
AND d.tecahnician like concat('%', #{tecahnician}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND date_format(d.datetime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
AND date_format(d.datetime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="sheepfold != null "> and d.sheepfold = #{sheepfold}</if>
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
</where>
order by d.datetime desc
</select>
<select id="selectSheepEarNumberList" resultType="String">
SELECT bs_manage_tags
FROM sheep_file
WHERE bs_manage_tags LIKE concat('%', #{query}, '%')
LIMIT 20
</select>
<select id="searchTechnicianList" resultType="String">
SELECT nick_name
FROM sys_user
WHERE nick_name LIKE concat('%', #{query}, '%')
LIMIT 20
</select>
<select id="selectScDryMilkById" parameterType="Long" resultMap="ScDryMilkResult">
<include refid="selectScDryMilkVo"/>
@@ -70,7 +89,7 @@
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByManageTags" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{manageTags}
select id from sheep_file where bs_manage_tags = #{manageTags} limit 1
</select>
<insert id="insertScDryMilk" parameterType="ScDryMilk" useGeneratedKeys="true" keyProperty="id">

View File

@@ -22,45 +22,119 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isDelete" column="is_delete" />
<result property="variety" column="variety" />
<result property="sheepType" column="sheep_type_name" />
<result property="gender" column="gender" />
<result property="dayAge" column="day_age" />
<result property="parity" column="parity" />
<result property="sheepfoldName" column="sheepfold_name" />
<result property="breedStatus" column="breed_status" />
<result property="postLambingDay" column="post_lambing_day" />
<result property="lactationDay" column="lactation_day" />
<result property="gestationDay" column="gestation_day" />
</resultMap>
<sql id="selectScSheepDeathVo">
select id, sheep_id, manage_tags, event_type, death_date, disease_type_id, disease_subtype_id, disposal_direction, technician, handler, work_group, create_by, create_time, comment, update_by, update_time, is_delete from sc_sheep_death d
left join sheep_file s on d.sheep_id = s.id
select d.id, d.sheep_id, d.manage_tags, d.event_type, d.death_date, d.disease_type_id, d.disease_subtype_id,
d.disposal_direction, d.technician, d.handler, d.work_group, d.create_by, d.create_time, d.comment,
d.update_by, d.update_time, d.is_delete,
s.variety, s.name as sheep_type_name, s.gender, s.day_age, s.parity, s.sheepfold_name,
s.breed as breed_status, s.post_lambing_day, s.lactation_day, s.gestation_day
from sc_sheep_death d
left join sheep_file s on d.manage_tags = s.bs_manage_tags
</sql>
<select id="selectScSheepDeathList" parameterType="ScSheepDeath" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
<where>
<!-- 全部羊多耳号查询 -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
<!-- 注意s 代表 sheep_file 表的别名,根据实际 SQL 别名修改 -->
s.bs_manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
<if test="sheepId != null "> and d.sheep_id = #{sheepId}</if>
<if test="manageTagsList != null and manageTagsList.size() > 0">
AND d.manage_tags IN
<foreach collection="manageTagsList" item="tag" open="(" separator="," close=")">
#{tag}
</foreach>
)
</if>
<if test="sheepId != null "> and sheep_id = #{sheepId}</if>
<if test="manageTags != null and manageTags != ''"> and manage_tags = #{manageTags}</if>
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
<if test="deathDate != null "> and death_date = #{deathDate}</if>
<if test="diseaseTypeId != null "> and disease_type_id = #{diseaseTypeId}</if>
<if test="diseaseSubtypeId != null "> and disease_subtype_id = #{diseaseSubtypeId}</if>
<if test="disposalDirection != null and disposalDirection != ''"> and disposal_direction = #{disposalDirection}</if>
<if test="technician != null and technician != ''"> and technician = #{technician}</if>
<if test="handler != null and handler != ''"> and handler = #{handler}</if>
<if test="workGroup != null and workGroup != ''"> and work_group = #{workGroup}</if>
<if test="comment != null and comment != ''"> and comment = #{comment}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="(manageTagsList == null or manageTagsList.size() == 0) and manageTags != null and manageTags != ''">
and d.manage_tags like concat('%', #{manageTags}, '%')
</if>
<if test="params.beginDeathDate != null and params.beginDeathDate != '' and params.endDeathDate != null and params.endDeathDate != ''">
and d.death_date between #{params.beginDeathDate} and #{params.endDeathDate}
</if>
<if test="eventType != null and eventType != ''"> and d.event_type = #{eventType}</if>
<if test="diseaseTypeId != null "> and d.disease_type_id = #{diseaseTypeId}</if>
<if test="diseaseSubtypeId != null "> and d.disease_subtype_id = #{diseaseSubtypeId}</if>
<if test="disposalDirection != null and disposalDirection != ''"> and d.disposal_direction = #{disposalDirection}</if>
<if test="technicianList != null and technicianList.size() > 0">
AND d.technician IN
<foreach collection="technicianList" item="tech" open="(" separator="," close=")">
#{tech}
</foreach>
</if>
<if test="(technicianList == null or technicianList.size() == 0) and technician != null and technician != ''">
and d.technician like concat('%', #{technician}, '%')
</if>
<if test="handlerList != null and handlerList.size() > 0">
AND d.handler IN
<foreach collection="handlerList" item="hand" open="(" separator="," close=")">
#{hand}
</foreach>
</if>
<if test="(handlerList == null or handlerList.size() == 0) and handler != null and handler != ''">
and d.handler like concat('%', #{handler}, '%')
</if>
<if test="workGroupList != null and workGroupList.size() > 0">
AND d.work_group IN
<foreach collection="workGroupList" item="grp" open="(" separator="," close=")">
#{grp}
</foreach>
</if>
<if test="(workGroupList == null or workGroupList.size() == 0) and workGroup != null and workGroup != ''">
and d.work_group = #{workGroup}
</if>
<if test="variety != null and variety != ''"> and s.variety like concat('%', #{variety}, '%')</if>
<if test="sheepTypeList != null and sheepTypeList.size() > 0">
AND s.name IN
<foreach collection="sheepTypeList" item="sType" open="(" separator="," close=")">
#{sType}
</foreach>
</if>
<if test="(sheepTypeList == null or sheepTypeList.size() == 0) and sheepType != null and sheepType != ''">
and s.name like concat('%', #{sheepType}, '%')
</if>
</where>
order by create_time desc
order by d.create_time desc
</select>
<select id="selectDistinctManageTags" resultType="String">
SELECT DISTINCT manage_tags FROM sc_sheep_death
WHERE manage_tags LIKE concat('%', #{query}, '%')
LIMIT 20
</select>
<select id="selectDistinctTechnician" resultType="String">
SELECT DISTINCT technician FROM sc_sheep_death
WHERE technician LIKE concat('%', #{query}, '%') AND technician IS NOT NULL AND technician != ''
LIMIT 20
</select>
<select id="selectDistinctHandler" resultType="String">
SELECT DISTINCT handler FROM sc_sheep_death
WHERE handler LIKE concat('%', #{query}, '%') AND handler IS NOT NULL AND handler != ''
LIMIT 20
</select>
<select id="selectScSheepDeathById" parameterType="Long" resultMap="ScSheepDeathResult">
<include refid="selectScSheepDeathVo"/>
where id = #{id}
where d.id = #{id}
</select>
<!-- 根据管理耳号查询sheep_file视图信息 -->

View File

@@ -15,7 +15,7 @@
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="electronicTags" column="electronic_tags" />
<!-- 关联查询的字段 -->
<result property="earNumber" column="bs_manage_tags" />
<result property="breed" column="variety" />
<result property="eventType" column="event_type" />
@@ -28,7 +28,6 @@
<result property="breedingStatus" column="breed" />
</resultMap>
<!-- 带关联查询的基础SQL -->
<sql id="selectScWeanRecordVo">
select
wr.id, wr.sheep_id, wr.datetime, wr.weight, wr.status, wr.technician,
@@ -40,7 +39,6 @@
left join sheep_file sf on wr.sheep_id = sf.id
</sql>
<!-- 查询断奶记录列表 -->
<select id="selectScWeanRecordList" parameterType="ScWeanRecord" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
<where>
@@ -54,8 +52,32 @@
)
</if>
<if test="sheepId != null "> and wr.sheep_id = #{sheepId}</if>
<if test="earNumber != null and earNumber != ''"> and sf.bs_manage_tags like concat('%', #{earNumber}, '%')</if>
<if test="datetime != null "> and wr.datetime = #{datetime}</if>
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND sf.bs_manage_tags IN
<foreach collection="allEarNumbers" item="ear" open="(" separator="," close=")">
#{ear}
</foreach>
</if>
<if test="(allEarNumbers == null or allEarNumbers.size() == 0) and earNumber != null and earNumber != ''">
and sf.bs_manage_tags like concat('%', #{earNumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND date_format(wr.datetime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
AND date_format(wr.datetime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="isInHerd != null and isInHerd != ''">
AND sf.status = #{isInHerd}
</if>
<if test="sheepCategory != null and sheepCategory != ''">
AND sf.breed = #{sheepCategory}
</if>
<if test="weight != null "> and wr.weight = #{weight}</if>
<if test="status != null "> and wr.status = #{status}</if>
<if test="technician != null and technician != ''"> and wr.technician like concat('%', #{technician}, '%')</if>
@@ -68,23 +90,27 @@
<if test="fatherNumber != null and fatherNumber != ''"> and sf.father_manage_tags like concat('%', #{fatherNumber}, '%')</if>
<if test="motherNumber != null and motherNumber != ''"> and sf.mother_manage_tags like concat('%', #{motherNumber}, '%')</if>
<if test="sheepPen != null and sheepPen != ''"> and sf.sheepfold_name like concat('%', #{sheepPen}, '%')</if>
<if test="breedingStatus != null and breedingStatus != ''"> and sf.breed = #{breedingStatus}</if>
</where>
order by wr.create_time desc
</select>
<!-- 根据ID查询断奶记录 -->
<select id="searchEarNumbers" resultType="String">
SELECT DISTINCT bs_manage_tags
FROM sheep_file
WHERE bs_manage_tags LIKE CONCAT('%', #{query}, '%')
AND is_delete = 0
LIMIT 20
</select>
<select id="selectScWeanRecordById" parameterType="Long" resultMap="ScWeanRecordResult">
<include refid="selectScWeanRecordVo"/>
where wr.id = #{id}
</select>
<!-- 根据耳号查询羊只ID -->
<select id="selectSheepIdByEarNumber" parameterType="String" resultType="Long">
select id from sheep_file where bs_manage_tags = #{earNumber}
</select>
<!-- 插入断奶记录 -->
<insert id="insertScWeanRecord" parameterType="ScWeanRecord" useGeneratedKeys="true" keyProperty="id">
insert into sc_wean_record
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -111,7 +137,6 @@
</trim>
</insert>
<!-- 更新断奶记录 -->
<update id="updateScWeanRecord" parameterType="ScWeanRecord">
update sc_wean_record
<trim prefix="SET" suffixOverrides=",">
@@ -128,23 +153,10 @@
where id = #{id}
</update>
<!-- 根据耳号更新bas_sheep表中的断奶信息 -->
<update id="updateBasSheepWeaningInfo" parameterType="ScWeanRecord">
update bas_sheep
<trim prefix="SET" suffixOverrides=",">
<if test="datetime != null">weaning_date = #{datetime},</if>
<if test="weight != null">weaning_weight = #{weight},</if>
<if test="electronicTags != null and electronicTags != ''">electronic_tags = #{electronicTags},</if>
</trim>
where manage_tags = #{earNumber}
</update>
<!-- 删除断奶记录 -->
<delete id="deleteScWeanRecordById" parameterType="Long">
delete from sc_wean_record where id = #{id}
</delete>
<!-- 批量删除断奶记录 -->
<delete id="deleteScWeanRecordByIds" parameterType="String">
delete from sc_wean_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">