Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
fe5dffb508
@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.base.controller;
|
package com.zhyc.module.base.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.zhyc.common.annotation.Log;
|
import com.zhyc.common.annotation.Log;
|
||||||
import com.zhyc.common.core.controller.BaseController;
|
import com.zhyc.common.core.controller.BaseController;
|
||||||
import com.zhyc.common.core.domain.AjaxResult;
|
import com.zhyc.common.core.domain.AjaxResult;
|
||||||
@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,14 +36,34 @@ public class SheepFileController extends BaseController
|
|||||||
* 查询羊只档案列表
|
* 查询羊只档案列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('sheep_file:sheep_file:list')")
|
@PreAuthorize("@ss.hasPermi('sheep_file:sheep_file:list')")
|
||||||
@PostMapping("/list") // 改为 POST 请求
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody(required = false) Map<String, Object> queryParams)
|
public TableDataInfo list(@RequestBody(required = false) Map<String, Object> queryParams, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
// 解析查询参数
|
// 解析查询参数
|
||||||
SheepFile sheepFile = new SheepFile();
|
SheepFile sheepFile = new SheepFile();
|
||||||
Map<String, Object> customParams = new HashMap<>();
|
Map<String, Object> customParams = new HashMap<>();
|
||||||
|
|
||||||
|
// 提取分页参数
|
||||||
|
Integer pageNum = 1;
|
||||||
|
Integer pageSize = 10;
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
// 提取分页参数
|
||||||
|
if (queryParams.containsKey("pageNum") && queryParams.get("pageNum") != null) {
|
||||||
|
try {
|
||||||
|
pageNum = Integer.parseInt(queryParams.get("pageNum").toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 使用默认值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (queryParams.containsKey("pageSize") && queryParams.get("pageSize") != null) {
|
||||||
|
try {
|
||||||
|
pageSize = Integer.parseInt(queryParams.get("pageSize").toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 使用默认值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 提取常规查询参数到 SheepFile 对象
|
// 提取常规查询参数到 SheepFile 对象
|
||||||
if (queryParams.containsKey("bsManageTags") && queryParams.get("bsManageTags") != null) {
|
if (queryParams.containsKey("bsManageTags") && queryParams.get("bsManageTags") != null) {
|
||||||
sheepFile.setBsManageTags(queryParams.get("bsManageTags").toString());
|
sheepFile.setBsManageTags(queryParams.get("bsManageTags").toString());
|
||||||
@ -69,12 +91,11 @@ public class SheepFileController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经处理的参数,剩下的作为自定义筛选参数
|
// 移除已经处理的参数,剩下的作为自定义筛选参数
|
||||||
// 注意:不直接修改原参数,而是复制到新Map中
|
|
||||||
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
|
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
|
|
||||||
// 跳过常规参数
|
// 跳过常规参数和分页参数
|
||||||
if ("bsManageTags".equals(key) || "electronicTags".equals(key) ||
|
if ("bsManageTags".equals(key) || "electronicTags".equals(key) ||
|
||||||
"drRanch".equals(key) || "variety".equals(key) ||
|
"drRanch".equals(key) || "variety".equals(key) ||
|
||||||
"name".equals(key) || "gender".equals(key) ||
|
"name".equals(key) || "gender".equals(key) ||
|
||||||
@ -90,13 +111,14 @@ public class SheepFileController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startPage(); // 分页处理
|
// 使用自定义分页参数
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
|
||||||
// 调用支持复杂查询的Service方法
|
// 调用支持复杂查询的Service方法
|
||||||
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile);
|
List<SheepFile> list = sheepFileService.selectSheepFileListByCondition(customParams, sheepFile);
|
||||||
|
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换对象为Long类型
|
* 转换对象为Long类型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
package com.zhyc.module.common.controller;
|
|
||||||
|
|
||||||
import com.zhyc.common.core.domain.AjaxResult;
|
|
||||||
import com.zhyc.module.common.domain.UserPost;
|
|
||||||
|
|
||||||
import com.zhyc.module.common.service.UserPostService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
//人员用户
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/user")
|
|
||||||
public class UserController {
|
|
||||||
@Autowired
|
|
||||||
UserPostService userPostService;
|
|
||||||
|
|
||||||
@GetMapping()
|
|
||||||
public AjaxResult getUserPost(String postCode){
|
|
||||||
List<UserPost> list = userPostService.getUserPostListByCode(postCode);
|
|
||||||
return AjaxResult.success(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.zhyc.module.common.controller;
|
||||||
|
|
||||||
|
import com.zhyc.common.core.domain.AjaxResult;
|
||||||
|
import com.zhyc.module.common.domain.Post;
|
||||||
|
import com.zhyc.module.common.domain.User;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.service.PostService;
|
||||||
|
import com.zhyc.module.common.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//人员用户
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/userPost")
|
||||||
|
public class UserPostController {
|
||||||
|
@Autowired
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PostService postService;
|
||||||
|
|
||||||
|
// 根据岗位编码获取用户
|
||||||
|
@GetMapping("/getUser")
|
||||||
|
public AjaxResult getUserPost(String postCode){
|
||||||
|
List<User> list = userService.getUserListByCode(postCode);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取岗位(部门)
|
||||||
|
@GetMapping("/getPost")
|
||||||
|
public AjaxResult getPost(){
|
||||||
|
List<Post> list = postService.selectPostList();
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.zhyc.module.common.domain;
|
||||||
|
|
||||||
|
import com.zhyc.common.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Post {
|
||||||
|
|
||||||
|
/** 岗位序号 */
|
||||||
|
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long postId;
|
||||||
|
|
||||||
|
/** 岗位编码 */
|
||||||
|
@Excel(name = "岗位编码")
|
||||||
|
private String postCode;
|
||||||
|
|
||||||
|
/** 岗位名称 */
|
||||||
|
@Excel(name = "岗位名称")
|
||||||
|
private String postName;
|
||||||
|
|
||||||
|
/** 岗位排序 */
|
||||||
|
@Excel(name = "岗位排序")
|
||||||
|
private Integer postSort;
|
||||||
|
|
||||||
|
/** 状态(0正常 1停用) */
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 用户是否存在此岗位标识 默认不存在 */
|
||||||
|
private boolean flag = false;
|
||||||
|
}
|
||||||
@ -1,9 +1,13 @@
|
|||||||
package com.zhyc.module.common.domain;
|
package com.zhyc.module.common.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UserPost {
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class User {
|
||||||
// 用户id
|
// 用户id
|
||||||
private String userId;
|
private String userId;
|
||||||
// 用户名
|
// 用户名
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.zhyc.module.common.mapper;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.domain.Post;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PostMapper {
|
||||||
|
|
||||||
|
@Select("select * from sys_post where status = '0' and post_name like '%部'")
|
||||||
|
List<Post> selectPostList();
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.zhyc.module.common.mapper;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.domain.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper {
|
||||||
|
|
||||||
|
List<User> getUserListByCode(String postCode);
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
package com.zhyc.module.common.mapper;
|
|
||||||
|
|
||||||
import com.zhyc.module.common.domain.UserPost;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface UserPostMapper {
|
|
||||||
|
|
||||||
List<UserPost> getUserPostListByCode(String postCode);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.zhyc.module.common.service;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.domain.Post;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PostService {
|
||||||
|
List<Post> selectPostList();
|
||||||
|
}
|
||||||
@ -1,9 +0,0 @@
|
|||||||
package com.zhyc.module.common.service;
|
|
||||||
|
|
||||||
import com.zhyc.module.common.domain.UserPost;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface UserPostService {
|
|
||||||
List<UserPost> getUserPostListByCode(String postCode);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.zhyc.module.common.service;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.domain.User;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
List<User> getUserListByCode(String postCode);
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.zhyc.module.common.service.impl;
|
||||||
|
|
||||||
|
import com.zhyc.module.common.domain.Post;
|
||||||
|
import com.zhyc.module.common.mapper.PostMapper;
|
||||||
|
import com.zhyc.module.common.service.PostService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PostServiceImpl implements PostService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PostMapper postMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Post> selectPostList() {
|
||||||
|
List<Post> list = postMapper.selectPostList();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,19 +1,20 @@
|
|||||||
package com.zhyc.module.common.service.impl;
|
package com.zhyc.module.common.service.impl;
|
||||||
|
|
||||||
import com.zhyc.module.common.domain.UserPost;
|
import com.zhyc.module.common.domain.User;
|
||||||
import com.zhyc.module.common.mapper.UserPostMapper;
|
import com.zhyc.module.common.mapper.UserMapper;
|
||||||
import com.zhyc.module.common.service.UserPostService;
|
import com.zhyc.module.common.service.UserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserPostServiceImpl implements UserPostService {
|
public class UserPostServiceImpl implements UserService {
|
||||||
@Autowired
|
@Autowired
|
||||||
UserPostMapper userPostMapper;
|
UserMapper userMapper;
|
||||||
@Override
|
@Override
|
||||||
public List<UserPost> getUserPostListByCode(String postCode) {
|
public List<User> getUserListByCode(String postCode) {
|
||||||
return userPostMapper.getUserPostListByCode(postCode);
|
return userMapper.getUserListByCode(postCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.produce.breed.mapper;
|
package com.zhyc.module.produce.breed.mapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.zhyc.module.produce.breed.domain.ScBreedRecord;
|
import com.zhyc.module.produce.breed.domain.ScBreedRecord;
|
||||||
@ -124,4 +125,16 @@ public interface ScBreedRecordMapper
|
|||||||
public List<ScBreedRecord> selectBreedRecordByMatingTime(@Param("sheepId") Long sheepId,
|
public List<ScBreedRecord> selectBreedRecordByMatingTime(@Param("sheepId") Long sheepId,
|
||||||
@Param("matingDateStart") String matingDateStart,
|
@Param("matingDateStart") String matingDateStart,
|
||||||
@Param("matingDateEnd") String matingDateEnd);
|
@Param("matingDateEnd") String matingDateEnd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加羊只配种次数并更新配种日期
|
||||||
|
*
|
||||||
|
* @param sheepId 羊只ID
|
||||||
|
* @param matingDate 配种日期
|
||||||
|
* @param updateBy 更新人
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int incrementSheepMatingCount(@Param("sheepId") Long sheepId,
|
||||||
|
@Param("matingDate") Date matingDate,
|
||||||
|
@Param("updateBy") String updateBy);
|
||||||
}
|
}
|
||||||
@ -75,12 +75,12 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
* @param scBreedRecord 配种记录
|
* @param scBreedRecord 配种记录
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
// @Override
|
||||||
public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
// public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
||||||
{
|
// {
|
||||||
scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
// scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
return scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
// return scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改配种记录
|
* 修改配种记录
|
||||||
@ -245,4 +245,48 @@ public class ScBreedRecordServiceImpl implements IScBreedRecordService
|
|||||||
{
|
{
|
||||||
return scBreedRecordMapper.selectBreedRecordByMatingTime(sheepId, startDate, endDate);
|
return scBreedRecordMapper.selectBreedRecordByMatingTime(sheepId, startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增配种记录
|
||||||
|
*
|
||||||
|
* @param scBreedRecord 配种记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertScBreedRecord(ScBreedRecord scBreedRecord)
|
||||||
|
{
|
||||||
|
// 设置创建时间
|
||||||
|
scBreedRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
|
// 插入配种记录
|
||||||
|
int result = scBreedRecordMapper.insertScBreedRecord(scBreedRecord);
|
||||||
|
|
||||||
|
// 如果插入成功,同步更新羊只的配种日期
|
||||||
|
if (result > 0 && scBreedRecord.getEweId() != null) {
|
||||||
|
try {
|
||||||
|
Long eweId = Long.parseLong(scBreedRecord.getEweId());
|
||||||
|
|
||||||
|
// // 方案1:只更新配种日期(推荐)
|
||||||
|
// scBreedRecordMapper.updateSheepMatingDate(
|
||||||
|
// eweId,
|
||||||
|
// scBreedRecord.getCreateTime(),
|
||||||
|
// scBreedRecord.getCreateBy()
|
||||||
|
// );
|
||||||
|
|
||||||
|
// 方案2:同时更新配种日期和配种次数(如果需要的话,取消下面注释)
|
||||||
|
scBreedRecordMapper.incrementSheepMatingCount(
|
||||||
|
eweId,
|
||||||
|
scBreedRecord.getCreateTime(),
|
||||||
|
scBreedRecord.getCreateBy()
|
||||||
|
);
|
||||||
|
|
||||||
|
log.info("同步更新羊只 {} 的配种日期成功", eweId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("同步更新羊只配种日期失败", e);
|
||||||
|
// 不影响主流程,只记录日志
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -2,16 +2,16 @@
|
|||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhyc.module.common.mapper.UserPostMapper">
|
<mapper namespace="com.zhyc.module.common.mapper.UserMapper">
|
||||||
|
|
||||||
<resultMap type="UserPost" id="UserPostResult">
|
<resultMap type="User" id="UserResult">
|
||||||
<result property="userId" column="user_id" />
|
<result property="userId" column="user_id" />
|
||||||
<result property="nickName" column="nick_name" />
|
<result property="nickName" column="nick_name" />
|
||||||
<result property="postName" column="post_name"/>
|
<result property="postName" column="post_name"/>
|
||||||
<result property="postCode" column="post_code" />
|
<result property="postCode" column="post_code" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getUserPostListByCode" resultMap="UserPostResult">
|
<select id="getUserPostListByCode" resultMap="UserResult">
|
||||||
SELECT u.user_id, nick_name , post_name , post_code
|
SELECT u.user_id, nick_name , post_name , post_code
|
||||||
FROM sys_role r
|
FROM sys_role r
|
||||||
JOIN sys_user_role ur ON r.role_id = ur.role_id
|
JOIN sys_user_role ur ON r.role_id = ur.role_id
|
||||||
@ -42,8 +42,76 @@
|
|||||||
<result property="isPregnancyChecked" column="is_pregnancy_checked" />
|
<result property="isPregnancyChecked" column="is_pregnancy_checked" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- <sql id="selectScBreedRecordVo">-->
|
||||||
|
<!-- select-->
|
||||||
|
<!-- br.id,-->
|
||||||
|
<!-- br.sheep_id,-->
|
||||||
|
<!-- br.ram_id,-->
|
||||||
|
<!-- br.ewe_id,-->
|
||||||
|
<!-- br.technician,-->
|
||||||
|
<!-- br.breed_drugs,-->
|
||||||
|
<!-- br.breed_type,-->
|
||||||
|
<!-- br.create_by,-->
|
||||||
|
<!-- br.create_time,-->
|
||||||
|
<!-- -- 母羊信息(从视图获取)-->
|
||||||
|
<!-- ewe_view.bs_manage_tags as ewe_manage_tags,-->
|
||||||
|
<!-- ewe_view.variety as ewe_variety,-->
|
||||||
|
<!-- ewe_view.parity as ewe_parity,-->
|
||||||
|
<!-- ewe_view.month_age as ewe_month_age,-->
|
||||||
|
<!-- ewe_view.sheepfold_name as ewe_sheepfold_name,-->
|
||||||
|
<!-- ewe_view.breed as ewe_breed_status,-->
|
||||||
|
<!-- ewe_view.controlled as ewe_controlled,-->
|
||||||
|
<!-- ewe_view.comment as ewe_comment,-->
|
||||||
|
<!-- ewe_view.dr_ranch as ranch_name,-->
|
||||||
|
<!-- ewe_view.name as sheep_type,-->
|
||||||
|
<!-- ewe_view.mating_total as mating_count,-->
|
||||||
|
<!-- -- 公羊信息(从视图获取)-->
|
||||||
|
<!-- ram_view.bs_manage_tags as ram_manage_tags,-->
|
||||||
|
<!-- ram_view.variety as ram_variety,-->
|
||||||
|
<!-- -- 配种方式显示(修改:增加3-冲胚、4-自然发情人工授精)-->
|
||||||
|
<!-- CASE br.breed_type-->
|
||||||
|
<!-- WHEN 1 THEN '同期发情'-->
|
||||||
|
<!-- WHEN 2 THEN '本交'-->
|
||||||
|
<!-- WHEN 3 THEN '冲胚'-->
|
||||||
|
<!-- WHEN 4 THEN '自然发情人工授精'-->
|
||||||
|
<!-- ELSE '未知'-->
|
||||||
|
<!-- END as mating_type,-->
|
||||||
|
<!-- -- 发情后配种时间(小时数)-->
|
||||||
|
<!-- TIMESTAMPDIFF(HOUR, br.create_time, NOW()) as time_since_planning,-->
|
||||||
|
<!-- -- 孕检相关信息-->
|
||||||
|
<!-- pr.datetime as pregnancy_check_date,-->
|
||||||
|
<!-- pr.result as pregnancy_result,-->
|
||||||
|
<!-- pr.way as pregnancy_way,-->
|
||||||
|
<!-- pr.fetus_count,-->
|
||||||
|
<!-- pr.technician as pregnancy_technician,-->
|
||||||
|
<!-- pr.remark as pregnancy_remark,-->
|
||||||
|
<!-- pr.id as pregnancy_record_id,-->
|
||||||
|
<!-- -- 配种到孕检间隔天数-->
|
||||||
|
<!-- CASE-->
|
||||||
|
<!-- WHEN pr.datetime IS NOT NULL THEN DATEDIFF(pr.datetime, br.create_time)-->
|
||||||
|
<!-- ELSE NULL-->
|
||||||
|
<!-- END as days_to_pregnancy_check,-->
|
||||||
|
<!-- -- 是否已孕检-->
|
||||||
|
<!-- CASE-->
|
||||||
|
<!-- WHEN pr.id IS NOT NULL THEN 1-->
|
||||||
|
<!-- ELSE 0-->
|
||||||
|
<!-- END as is_pregnancy_checked-->
|
||||||
|
<!-- from sc_breed_record br-->
|
||||||
|
<!-- left join sheep_file ewe_view on br.ewe_id = ewe_view.id-->
|
||||||
|
<!-- left join sheep_file ram_view on br.ram_id = ram_view.id-->
|
||||||
|
<!-- left join sc_pregnancy_record pr on pr.sheep_id = br.ewe_id-->
|
||||||
|
<!-- and pr.is_delete = 0-->
|
||||||
|
<!-- and pr.datetime >= br.create_time-->
|
||||||
|
<!-- and pr.datetime = (-->
|
||||||
|
<!-- select min(pr2.datetime)-->
|
||||||
|
<!-- from sc_pregnancy_record pr2-->
|
||||||
|
<!-- where pr2.sheep_id = br.ewe_id-->
|
||||||
|
<!-- and pr2.is_delete = 0-->
|
||||||
|
<!-- and pr2.datetime >= br.create_time-->
|
||||||
|
<!-- )-->
|
||||||
|
<!-- </sql>-->
|
||||||
<sql id="selectScBreedRecordVo">
|
<sql id="selectScBreedRecordVo">
|
||||||
select
|
select DISTINCT
|
||||||
br.id,
|
br.id,
|
||||||
br.sheep_id,
|
br.sheep_id,
|
||||||
br.ram_id,
|
br.ram_id,
|
||||||
@ -68,7 +136,7 @@
|
|||||||
-- 公羊信息(从视图获取)
|
-- 公羊信息(从视图获取)
|
||||||
ram_view.bs_manage_tags as ram_manage_tags,
|
ram_view.bs_manage_tags as ram_manage_tags,
|
||||||
ram_view.variety as ram_variety,
|
ram_view.variety as ram_variety,
|
||||||
-- 配种方式显示(修改:增加3-冲胚、4-自然发情人工授精)
|
-- 配种方式显示
|
||||||
CASE br.breed_type
|
CASE br.breed_type
|
||||||
WHEN 1 THEN '同期发情'
|
WHEN 1 THEN '同期发情'
|
||||||
WHEN 2 THEN '本交'
|
WHEN 2 THEN '本交'
|
||||||
@ -99,18 +167,17 @@
|
|||||||
from sc_breed_record br
|
from sc_breed_record br
|
||||||
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
left join sheep_file ewe_view on br.ewe_id = ewe_view.id
|
||||||
left join sheep_file ram_view on br.ram_id = ram_view.id
|
left join sheep_file ram_view on br.ram_id = ram_view.id
|
||||||
left join sc_pregnancy_record pr on pr.sheep_id = br.ewe_id
|
-- 修复:使用子查询确保只返回一条孕检记录
|
||||||
and pr.is_delete = 0
|
left join sc_pregnancy_record pr on pr.id = (
|
||||||
and pr.datetime >= br.create_time
|
select pr2.id
|
||||||
and pr.datetime = (
|
from sc_pregnancy_record pr2
|
||||||
select min(pr2.datetime)
|
where pr2.sheep_id = br.ewe_id
|
||||||
from sc_pregnancy_record pr2
|
and pr2.is_delete = 0
|
||||||
where pr2.sheep_id = br.ewe_id
|
and pr2.datetime >= br.create_time
|
||||||
and pr2.is_delete = 0
|
order by pr2.datetime asc, pr2.id asc
|
||||||
and pr2.datetime >= br.create_time
|
limit 1
|
||||||
)
|
)
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
<select id="selectScBreedRecordList" parameterType="ScBreedRecord" resultMap="ScBreedRecordResult">
|
||||||
<include refid="selectScBreedRecordVo"/>
|
<include refid="selectScBreedRecordVo"/>
|
||||||
<where>
|
<where>
|
||||||
@ -338,4 +405,16 @@
|
|||||||
set pregnancy_record_id = #{pregnancyRecordId}
|
set pregnancy_record_id = #{pregnancyRecordId}
|
||||||
where id = #{breedRecordId}
|
where id = #{breedRecordId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<!-- 如果还需要更新配种次数(可选) -->
|
||||||
|
<update id="incrementSheepMatingCount">
|
||||||
|
update bas_sheep
|
||||||
|
set mating_counts = IFNULL(mating_counts, 0) + 1,
|
||||||
|
mating_total = IFNULL(mating_total, 0) + 1,
|
||||||
|
mating_date = #{matingDate},
|
||||||
|
update_time = NOW(),
|
||||||
|
update_by = #{updateBy}
|
||||||
|
where id = #{sheepId}
|
||||||
|
and is_delete = 0
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user