Merge remote-tracking branch 'origin/main'

This commit is contained in:
zyk
2026-02-01 09:58:57 +08:00
60 changed files with 622 additions and 86 deletions

View File

@@ -76,6 +76,9 @@ public class SysDeptController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept) public AjaxResult add(@Validated @RequestBody SysDept dept)
{ {
if (!deptService.checkRanchName(dept)){
return error("新增部门'" + dept.getDeptName() + "'失败,牧场名称已存在");
}
if (!deptService.checkDeptNameUnique(dept)) if (!deptService.checkDeptNameUnique(dept))
{ {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");

View File

@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
* *
* @author ruoyi * @author ruoyi
*/ */
@Target(ElementType.METHOD) @Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
public @interface DataScope public @interface DataScope

View File

@@ -31,6 +31,10 @@ public class SysDept extends BaseEntity
/** 部门名称 */ /** 部门名称 */
private String deptName; private String deptName;
/** 牧场id */
private Long ranchId;
private String ranchName;
/** 显示顺序 */ /** 显示顺序 */
private Integer orderNum; private Integer orderNum;
@@ -55,6 +59,22 @@ public class SysDept extends BaseEntity
/** 子部门 */ /** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>(); private List<SysDept> children = new ArrayList<SysDept>();
public String getRanchName() {
return ranchName;
}
public void setRanchName(String ranchName) {
this.ranchName = ranchName;
}
public Long getRanchId() {
return ranchId;
}
public void setRanchId(Long ranchId) {
this.ranchId = ranchId;
}
public Long getDeptId() public Long getDeptId()
{ {
return deptId; return deptId;

View File

@@ -0,0 +1,36 @@
package com.zhyc.common.core.domain.entity;
import com.zhyc.common.core.domain.BaseEntity;
/**
* 牧场管理对象 da_ranch
*
* @author ruoyi
* @date 2025-07-22
*/
public class SysRanch extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 牧场名称 */
private String ranch;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRanch() {
return ranch;
}
public void setRanch(String ranch) {
this.ranch = ranch;
}
}

View File

@@ -14,7 +14,7 @@ import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.framework.security.context.AuthenticationContextHolder; import com.zhyc.framework.security.context.AuthenticationContextHolder;
/** /**
* 登录密码方法 * 系统密码服务类,用于处理登录密码验证相关的业务逻辑,包括密码错误次数限制、账户锁定等功能
* *
* @author ruoyi * @author ruoyi
*/ */
@@ -31,7 +31,7 @@ public class SysPasswordService
private int lockTime; private int lockTime;
/** /**
* 登录账户密码错误次数缓存键名 * 构建登录账户密码错误次数缓存键名
* *
* @param username 用户名 * @param username 用户名
* @return 缓存键key * @return 缓存键key
@@ -41,12 +41,21 @@ public class SysPasswordService
return CacheConstants.PWD_ERR_CNT_KEY + username; return CacheConstants.PWD_ERR_CNT_KEY + username;
} }
/**
* 验证用户登录信息,包括密码匹配验证和错误次数限制检查
*
* @param user 待验证的系统用户对象
* @throws UserPasswordRetryLimitExceedException 当密码错误次数超过限制时抛出异常
* @throws UserPasswordNotMatchException 当密码不匹配时抛出异常
*/
public void validate(SysUser user) public void validate(SysUser user)
{ {
// 获取当前认证的用户名和密码
Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext(); Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
String username = usernamePasswordAuthenticationToken.getName(); String username = usernamePasswordAuthenticationToken.getName();
String password = usernamePasswordAuthenticationToken.getCredentials().toString(); String password = usernamePasswordAuthenticationToken.getCredentials().toString();
// 从Redis缓存中获取该用户的密码错误次数
Integer retryCount = redisCache.getCacheObject(getCacheKey(username)); Integer retryCount = redisCache.getCacheObject(getCacheKey(username));
if (retryCount == null) if (retryCount == null)
@@ -54,28 +63,44 @@ public class SysPasswordService
retryCount = 0; retryCount = 0;
} }
// 检查是否达到最大重试次数限制
if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
{ {
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime); throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
} }
// 验证密码是否匹配
if (!matches(user, password)) if (!matches(user, password))
{ {
// 密码不匹配时,增加错误次数并更新缓存
retryCount = retryCount + 1; retryCount = retryCount + 1;
redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
throw new UserPasswordNotMatchException(); throw new UserPasswordNotMatchException();
} }
else else
{ {
// 密码匹配成功,清除登录记录缓存
clearLoginRecordCache(username); clearLoginRecordCache(username);
} }
} }
/**
* 验证原始密码与用户存储密码是否匹配
*
* @param user 系统用户对象
* @param rawPassword 原始密码字符串
* @return 密码匹配返回true否则返回false
*/
public boolean matches(SysUser user, String rawPassword) public boolean matches(SysUser user, String rawPassword)
{ {
return SecurityUtils.matchesPassword(rawPassword, user.getPassword()); return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
} }
/**
* 清除指定登录名的登录记录缓存
*
* @param loginName 登录用户名
*/
public void clearLoginRecordCache(String loginName) public void clearLoginRecordCache(String loginName)
{ {
if (redisCache.hasKey(getCacheKey(loginName))) if (redisCache.hasKey(getCacheKey(loginName)))

View File

@@ -54,7 +54,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
throw new ServiceException(MessageUtils.message("user.blocked")); throw new ServiceException(MessageUtils.message("user.blocked"));
} }
passwordService.validate(user); // passwordService.validate(user);
return createLoginUser(user); return createLoginUser(user);
} }

View File

@@ -46,6 +46,18 @@ public class BasSheepController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
//查询耳号列表
@GetMapping("/earNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try {
List<String> earNumbers =basSheepService.searchEarNumbers(query);
return success(earNumbers);
} catch (Exception e) {
logger.error("搜索耳号异常", e);
return error("搜索耳号失败:" + e.getMessage());
}
}
/** /**
* 导出羊只基本信息列表 * 导出羊只基本信息列表
*/ */

View File

@@ -70,6 +70,15 @@ public interface BasSheepMapper
BasSheep selectBasSheepByManageTags(String manageTags); BasSheep selectBasSheepByManageTags(String manageTags);
/**
* 模糊查询母羊耳号列表
*
* @param query 查询关键字
* @return 耳号列表
*/
List<String> searchEarNumbers(@Param("query") String query);
List<BasSheep> selectBasSheepBySheepfold(String id); List<BasSheep> selectBasSheepBySheepfold(String id);
// 根据牧场ID获取羊只列表 // 根据牧场ID获取羊只列表

View File

@@ -28,6 +28,13 @@ public interface IBasSheepService
*/ */
public List<BasSheep> selectBasSheepList(BasSheep basSheep); public List<BasSheep> selectBasSheepList(BasSheep basSheep);
/**
* 羊只查询耳号信息
*
* @param earNumbers 耳号
* @return 结果
*/
public List<String> searchEarNumbers(String earNumbers);
/** /**
* 新增羊只基本信息 * 新增羊只基本信息
* *

View File

@@ -1,6 +1,8 @@
package com.zhyc.module.base.service.impl; package com.zhyc.module.base.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.mapper.BasSheepMapper; import com.zhyc.module.base.mapper.BasSheepMapper;
@@ -44,6 +46,17 @@ public class BasSheepServiceImpl implements IBasSheepService
return basSheepMapper.selectBasSheepList(basSheep); return basSheepMapper.selectBasSheepList(basSheep);
} }
/**
* 搜索羊只 earNumbers
*
* @param query
* @return
*/
@Override
@DataScope(deptAlias = "b", userAlias = "b")
public List<String> searchEarNumbers(String query) {
return basSheepMapper.searchEarNumbers(query);
}
/** /**
* 新增羊只基本信息 * 新增羊只基本信息
* *

View File

@@ -78,7 +78,8 @@ public class DewormController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Deworm deworm) public AjaxResult add(@RequestBody Deworm deworm)
{ {
System.out.println(deworm); deworm.setDeptId(getDeptId());
deworm.setUserId(getUserId());
return toAjax(dewormService.insertDeworm(deworm)); return toAjax(dewormService.insertDeworm(deworm));
} }

View File

@@ -77,6 +77,8 @@ public class DiagnosisController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Diagnosis diagnosis) public AjaxResult add(@RequestBody Diagnosis diagnosis)
{ {
diagnosis.setDeptId(getDeptId());
diagnosis.setUserId(getUserId());
return toAjax(diagnosisService.insertDiagnosis(diagnosis)); return toAjax(diagnosisService.insertDiagnosis(diagnosis));
} }

View File

@@ -78,6 +78,8 @@ public class DisinfectController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Disinfect disinfect) public AjaxResult add(@RequestBody Disinfect disinfect)
{ {
disinfect.setDeptId(getDeptId());
disinfect.setUserId(getUserId());
return toAjax(disinfectService.insertDisinfect(disinfect)); return toAjax(disinfectService.insertDisinfect(disinfect));
} }

View File

@@ -79,6 +79,8 @@ public class HealthController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Health health) public AjaxResult add(@RequestBody Health health)
{ {
health.setDeptId(getDeptId());
health.setUserId(getUserId());
return toAjax(healthService.insertHealth(health)); return toAjax(healthService.insertHealth(health));
} }

View File

@@ -78,6 +78,8 @@ public class ImmunityController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Immunity immunity) public AjaxResult add(@RequestBody Immunity immunity)
{ {
immunity.setDeptId(getDeptId());
immunity.setUserId(getUserId());
return toAjax(immunityService.insertImmunity(immunity)); return toAjax(immunityService.insertImmunity(immunity));
} }

View File

@@ -78,6 +78,8 @@ public class QuarantineReportController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody QuarantineReport quarantineReport) public AjaxResult add(@RequestBody QuarantineReport quarantineReport)
{ {
quarantineReport.setDeptId(getDeptId());
quarantineReport.setUserId(getUserId());
return toAjax(quarantineReportService.insertQuarantineReport(quarantineReport)); return toAjax(quarantineReportService.insertQuarantineReport(quarantineReport));
} }

View File

@@ -84,6 +84,8 @@ public class SwMedicineUsageController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SwMedicineUsage swMedicineUsage) public AjaxResult add(@RequestBody SwMedicineUsage swMedicineUsage)
{ {
swMedicineUsage.setDeptId(getDeptId());
swMedicineUsage.setUserId(getUserId());
return toAjax(swMedicineUsageService.insertSwMedicineUsage(swMedicineUsage)); return toAjax(swMedicineUsageService.insertSwMedicineUsage(swMedicineUsage));
} }

View File

@@ -78,6 +78,8 @@ public class TreatmentController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Treatment treatment) public AjaxResult add(@RequestBody Treatment treatment)
{ {
treatment.setDeptId(getDeptId());
treatment.setUserId(getUserId());
return toAjax(treatmentService.insertTreatment(treatment)); return toAjax(treatmentService.insertTreatment(treatment));
} }

View File

@@ -35,6 +35,8 @@ public class Deworm extends BaseEntity
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
@Excel(name = "品种") @Excel(name = "品种")
private String variety; private String variety;
@@ -52,7 +54,8 @@ public class Deworm extends BaseEntity
@Excel(name = "胎次") @Excel(name = "胎次")
private Long parity; private Long parity;
private Long userId;
private Long deptId;
/** 药品使用记录 */ /** 药品使用记录 */
@Excel(name = "药品使用记录") @Excel(name = "药品使用记录")
@@ -75,11 +78,9 @@ public class Deworm extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;
// public void setGender(String gender) {
// this.gender = gender;
// this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
// }
// 排序查询 // 排序查询
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
} }

View File

@@ -1,6 +1,8 @@
package com.zhyc.module.biosafety.domain; package com.zhyc.module.biosafety.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.module.enums.Gender; import com.zhyc.module.enums.Gender;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -38,6 +40,9 @@ public class Diagnosis extends BaseEntity
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
private Long sheepId; private Long sheepId;
@@ -97,12 +102,26 @@ public class Diagnosis extends BaseEntity
private Long sheepfoldId; private Long sheepfoldId;
public void setGender(String gender) {
this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
}
// 排序查询 // 排序查询
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
private Long userId;
private Long deptId;
public void setGender(String gender) {
this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) {
try {
Integer genderCode = Integer.valueOf(gender.trim());
this.genderName = Gender.getDescByCode(genderCode);
} catch (NumberFormatException e) {
// 如果转换失败,设置为空或默认值
this.genderName = null;
}
} else {
this.genderName = null;
}
}
} }

View File

@@ -61,6 +61,9 @@ public class Disinfect extends BaseEntity
/** 药品名称用于查询*/ /** 药品名称用于查询*/
private String mediName; private String mediName;
private Long userId;
private Long deptId;
// 药品使用 // 药品使用
private List<SwMedicineUsageDetails> usageDetails; private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -31,13 +31,15 @@ public class Health extends BaseEntity
/** 羊只id */ /** 羊只id */
@Excel(name = "羊只id") @Excel(name = "羊只id")
private Long sheepId; private Long sheepId;
private Integer[] sheepIds; private Integer[] sheepIds;
/** 羊只id */ /** 羊只id */
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
@Excel(name = "品种") @Excel(name = "品种")
private String variety; private String variety;
@@ -67,14 +69,29 @@ public class Health extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;
private Long userId;
private Long deptId;
// 药品使用 // 药品使用
private List<SwMedicineUsageDetails> usageDetails; private List<SwMedicineUsageDetails> usageDetails;
public void setGender(String gender) {
this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
}
// 排序查询 // 排序查询
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
public void setGender(String gender) {
this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) {
try {
Integer genderCode = Integer.valueOf(gender.trim());
this.genderName = Gender.getDescByCode(genderCode);
} catch (NumberFormatException e) {
// 如果转换失败,设置为空或默认值
this.genderName = null;
}
} else {
this.genderName = null;
}
}
} }

View File

@@ -37,6 +37,9 @@ public class Immunity extends BaseEntity
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
@Excel(name = "品种") @Excel(name = "品种")
@@ -75,14 +78,29 @@ public class Immunity extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;
private Long userId;
private Long deptId;
// 药品使用 // 药品使用
private List<SwMedicineUsageDetails> usageDetails; private List<SwMedicineUsageDetails> usageDetails;
public void setGender(String gender) {
this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
}
// 排序查询 // 排序查询
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
public void setGender(String gender) {
this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) {
try {
Integer genderCode = Integer.valueOf(gender.trim());
this.genderName = Gender.getDescByCode(genderCode);
} catch (NumberFormatException e) {
// 如果转换失败,设置为空或默认值
this.genderName = null;
}
} else {
this.genderName = null;
}
}
} }

View File

@@ -1,6 +1,8 @@
package com.zhyc.module.biosafety.domain; package com.zhyc.module.biosafety.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhyc.module.enums.Gender; import com.zhyc.module.enums.Gender;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -37,6 +39,9 @@ public class QuarantineReport extends BaseEntity
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
@Excel(name = "羊只类别") @Excel(name = "羊只类别")
private String sheepType; private String sheepType;
@@ -93,6 +98,9 @@ public class QuarantineReport extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String comment; private String comment;
private Long userId;
private Long deptId;
public void setGender(String gender) { public void setGender(String gender) {
this.gender = gender; this.gender = gender;
this.genderName = Gender.getDescByCode(Integer.valueOf(gender)); this.genderName = Gender.getDescByCode(Integer.valueOf(gender));

View File

@@ -38,6 +38,11 @@ public class SwMedicineUsage extends BaseEntity
/** 耳号 */ /** 耳号 */
@Excel(name = "耳号",width = 20, needMerge = true) @Excel(name = "耳号",width = 20, needMerge = true)
private String sheepNo; private String sheepNo;
private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
private Integer sheepId; private Integer sheepId;
/** 使用时间 */ /** 使用时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@@ -48,6 +53,9 @@ public class SwMedicineUsage extends BaseEntity
@Excel(name = "使用类型",width = 20, needMerge = true) @Excel(name = "使用类型",width = 20, needMerge = true)
private String useType; private String useType;
private Long userId;
private Long deptId;
/** 药品使用记录详情信息 */ /** 药品使用记录详情信息 */
@Excel @Excel
private List<SwMedicineUsageDetails> swMedicineUsageDetailsList; private List<SwMedicineUsageDetails> swMedicineUsageDetailsList;

View File

@@ -33,6 +33,9 @@ public class Treatment extends BaseEntity
@Excel(name = "羊只耳号") @Excel(name = "羊只耳号")
private String sheepNo; private String sheepNo;
private String[] sheepNos; private String[] sheepNos;
/** 全部羊耳号列表(用于多耳号查询) */
private List<String> allEarNumbers;
private Long sheepId; private Long sheepId;
// 用于批量新增 // 用于批量新增
@@ -101,6 +104,9 @@ public class Treatment extends BaseEntity
@Excel(name = "药品使用记录id") @Excel(name = "药品使用记录id")
private Integer usageId; private Integer usageId;
private Long userId;
private Long deptId;
// 药品使用 // 药品使用
private List<SwMedicineUsageDetails> usageDetails; private List<SwMedicineUsageDetails> usageDetails;

View File

@@ -3,6 +3,8 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -58,6 +60,7 @@ public class DewormServiceImpl implements IDewormService
* @return 驱虫 * @return 驱虫
*/ */
@Override @Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Deworm> selectDewormList(Deworm deworm) public List<Deworm> selectDewormList(Deworm deworm)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.base.domain.BasSheep; import com.zhyc.module.base.domain.BasSheep;
@@ -60,6 +61,7 @@ public class DiagnosisServiceImpl implements IDiagnosisService
* @return 诊疗结果 * @return 诊疗结果
*/ */
@Override @Override
@DataScope(deptAlias = "sd", userAlias = "sd")
public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis) public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -59,6 +61,7 @@ public class DisinfectServiceImpl implements IDisinfectService
* @return 消毒记录 * @return 消毒记录
*/ */
@Override @Override
@DataScope(deptAlias = "sd", userAlias = "sd")
public List<Disinfect> selectDisinfectList(Disinfect disinfect) public List<Disinfect> selectDisinfectList(Disinfect disinfect)
{ {
return disinfectMapper.selectDisinfectList(disinfect); return disinfectMapper.selectDisinfectList(disinfect);

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -62,6 +63,7 @@ public class HealthServiceImpl implements IHealthService
* @return 保健 * @return 保健
*/ */
@Override @Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Health> selectHealthList(Health health) public List<Health> selectHealthList(Health health)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -61,6 +63,7 @@ public class ImmunityServiceImpl implements IImmunityService
* @return 免疫 * @return 免疫
*/ */
@Override @Override
@DataScope(deptAlias = "s", userAlias = "s")
public List<Immunity> selectImmunityList(Immunity immunity) public List<Immunity> selectImmunityList(Immunity immunity)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.module.biosafety.domain.QuarantineItems; import com.zhyc.module.biosafety.domain.QuarantineItems;
import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper; import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper;
import com.zhyc.module.biosafety.service.IQuarantineItemsService; import com.zhyc.module.biosafety.service.IQuarantineItemsService;

View File

@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -46,6 +48,7 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
* @return 检疫记录 * @return 检疫记录
*/ */
@Override @Override
@DataScope(deptAlias = "sqr", userAlias = "sqr")
public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport) public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -1,6 +1,8 @@
package com.zhyc.module.biosafety.service.impl; package com.zhyc.module.biosafety.service.impl;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.biosafety.service.ISwMedicineUsageService; import com.zhyc.module.biosafety.service.ISwMedicineUsageService;
@@ -44,8 +46,17 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
* @return 药品使用记录 * @return 药品使用记录
*/ */
@Override @Override
@DataScope(deptAlias = "smu", userAlias = "smu")
public List<SwMedicineUsage> selectSwMedicineUsageList(SwMedicineUsage swMedicineUsage) public List<SwMedicineUsage> selectSwMedicineUsageList(SwMedicineUsage swMedicineUsage)
{ {
String[] sheepNos = null;
if (swMedicineUsage.getSheepNo() != null && !swMedicineUsage.getSheepNo().isEmpty()) {
if (swMedicineUsage.getSheepNo().contains(" ")) {
sheepNos = swMedicineUsage.getSheepNo().split(" ");
swMedicineUsage.setSheepNos(sheepNos);
swMedicineUsage.setSheepNo(null);
}
}
return swMedicineUsageMapper.selectSwMedicineUsageList(swMedicineUsage); return swMedicineUsageMapper.selectSwMedicineUsageList(swMedicineUsage);
} }

View File

@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.DateUtils; import com.zhyc.common.utils.DateUtils;
import com.zhyc.common.utils.SecurityUtils; import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.common.utils.bean.BeanUtils; import com.zhyc.common.utils.bean.BeanUtils;
@@ -65,6 +67,7 @@ public class TreatmentServiceImpl implements ITreatmentService
* @return 治疗记录 * @return 治疗记录
*/ */
@Override @Override
@DataScope(deptAlias = "t", userAlias = "t")
public List<Treatment> selectTreatmentList(Treatment treatment) public List<Treatment> selectTreatmentList(Treatment treatment)
{ {
String[] sheepNos = null; String[] sheepNos = null;

View File

@@ -26,7 +26,9 @@ public class UserPostController {
// 根据岗位编码获取用户 // 根据岗位编码获取用户
@GetMapping("/getUser") @GetMapping("/getUser")
public AjaxResult getUserPost(String postCode){ public AjaxResult getUserPost(String postCode){
List<User> list = userService.getUserListByCode(postCode); User user = new User();
user.setPostCode(postCode);
List<User> list = userService.getUserListByCode(user);
return AjaxResult.success(list); return AjaxResult.success(list);
} }

View File

@@ -0,0 +1,22 @@
package com.zhyc.module.common.domain;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Dept extends BaseEntity {
private Long deptId;
private Long parentId;
private String ancestors;
private String deptName;
private String orderNum;
private String leader;
private String phone;
private String email;
private String status;
private String delFlag;
}

View File

@@ -1,6 +1,7 @@
package com.zhyc.module.common.domain; package com.zhyc.module.common.domain;
import com.zhyc.common.annotation.Excel; import com.zhyc.common.annotation.Excel;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -8,7 +9,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class Post { public class Post extends BaseEntity {
/** 岗位序号 */ /** 岗位序号 */
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)

View File

@@ -1,5 +1,6 @@
package com.zhyc.module.common.domain; package com.zhyc.module.common.domain;
import com.zhyc.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -7,9 +8,10 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class User { public class User extends BaseEntity {
// 用户id // 用户id
private String userId; private Long userId;
private Long deptId;
// 用户名 // 用户名
private String nickName; private String nickName;
// 岗位名称 // 岗位名称
@@ -17,4 +19,5 @@ public class User {
// 岗位编码 // 岗位编码
private String postCode; private String postCode;
} }

View File

@@ -0,0 +1,15 @@
package com.zhyc.module.common.mapper;
import com.zhyc.module.common.domain.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface DeptMapper {
/**
* 根据部门ID查询其所属二级部门排除根部门
*/
Dept selectTopSecondLevelDept(Long deptId);
}

View File

@@ -8,5 +8,5 @@ import java.util.List;
@Mapper @Mapper
public interface UserMapper { public interface UserMapper {
List<User> getUserListByCode(String postCode); List<User> getUserListByCode(User user);
} }

View File

@@ -5,5 +5,5 @@ import com.zhyc.module.common.domain.User;
import java.util.List; import java.util.List;
public interface UserService { public interface UserService {
List<User> getUserListByCode(String postCode); List<User> getUserListByCode(User postCode);
} }

View File

@@ -1,6 +1,10 @@
package com.zhyc.module.common.service.impl; package com.zhyc.module.common.service.impl;
import com.zhyc.common.annotation.DataScope;
import com.zhyc.common.utils.SecurityUtils;
import com.zhyc.module.common.domain.Dept;
import com.zhyc.module.common.domain.User; import com.zhyc.module.common.domain.User;
import com.zhyc.module.common.mapper.DeptMapper;
import com.zhyc.module.common.mapper.UserMapper; import com.zhyc.module.common.mapper.UserMapper;
import com.zhyc.module.common.service.UserService; import com.zhyc.module.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -12,9 +16,16 @@ import java.util.List;
public class UserPostServiceImpl implements UserService { public class UserPostServiceImpl implements UserService {
@Autowired @Autowired
UserMapper userMapper; UserMapper userMapper;
@Autowired
DeptMapper deptMapper;
@Override @Override
public List<User> getUserListByCode(String postCode) { public List<User> getUserListByCode(User user) {
return userMapper.getUserListByCode(postCode); Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
Dept secondLevel = deptMapper.selectTopSecondLevelDept(deptId);
user.setDeptId(secondLevel.getDeptId());
System.out.println(secondLevel);
return userMapper.getUserListByCode(user);
} }
} }

View File

@@ -148,6 +148,18 @@
WHERE s.id = #{id} WHERE s.id = #{id}
</select> </select>
<select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT manage_tags
FROM bas_sheep b
<where>
manage_tags LIKE CONCAT(#{query}, '%')
AND is_delete = 0
${params.dataScope}
</where>
ORDER by manage_tags
LIMIT 50
</select>
<select id="selectBasSheepByManageTags" parameterType="String" resultMap="BasSheepResult"> <select id="selectBasSheepByManageTags" parameterType="String" resultMap="BasSheepResult">
SELECT s.*, SELECT s.*,
bv.variety AS varietyName bv.variety AS varietyName

View File

@@ -6,18 +6,18 @@
<resultMap type="DaRanch" id="DaRanchResult"> <resultMap type="DaRanch" id="DaRanchResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="ranch" column="ranch"/> <result property="sysRanch" column="sysRanch"/>
</resultMap> </resultMap>
<sql id="selectDaRanchVo"> <sql id="selectDaRanchVo">
select id, ranch select id, sysRanch
from da_ranch from da_ranch
</sql> </sql>
<select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult"> <select id="selectDaRanchList" parameterType="DaRanch" resultMap="DaRanchResult">
<include refid="selectDaRanchVo"/> <include refid="selectDaRanchVo"/>
<where> <where>
<if test="ranch != null and ranch != ''">and ranch = #{ranch}</if> <if test="sysRanch != null and sysRanch != ''">and sysRanch = #{sysRanch}</if>
</where> </where>
</select> </select>
@@ -29,17 +29,17 @@
<insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDaRanch" parameterType="DaRanch" useGeneratedKeys="true" keyProperty="id">
insert into da_ranch insert into da_ranch
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ranch != null">ranch,</if> <if test="sysRanch != null">sysRanch,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ranch != null">#{ranch},</if> <if test="sysRanch != null">#{sysRanch},</if>
</trim> </trim>
</insert> </insert>
<update id="updateDaRanch" parameterType="DaRanch"> <update id="updateDaRanch" parameterType="DaRanch">
update da_ranch update da_ranch
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="ranch != null">ranch = #{ranch},</if> <if test="sysRanch != null">sysRanch = #{sysRanch},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -43,11 +43,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> <if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''">
and datetime between #{params.beginDatetime} and #{params.endDatetime} and datetime between #{params.beginDatetime} and #{params.endDatetime}
</if> </if>
<if test="technical != null and technical != ''">and technical = #{technical}</if> <if test="technical != null and technical != ''">and technical = #{technical}</if>
${params.dataScope}
</where> </where>
<!-- 基准排序:日期永远第一序,降序 --> <!-- 基准排序:日期永远第一序,降序 -->
@@ -68,13 +79,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sw_deworm insert into sw_deworm
(sheep_id, usage_id, variety, sheep_type, gender, month_age, (sheep_id, usage_id, variety, sheep_type, gender, month_age,
parity, breed,datetime, technical, comment, parity, breed,datetime, technical, comment,
update_by, update_time, create_by, create_time) update_by, update_time, create_by, create_time,user_id, dept_id)
values values
<foreach collection="list" item="d" separator=","> <foreach collection="list" item="d" separator=",">
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType}, (#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime}, #{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
#{d.technical}, #{d.comment}, #{d.technical}, #{d.comment},
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime}) #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
</foreach> </foreach>
</insert> </insert>

View File

@@ -52,12 +52,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if> <if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="diseasePid != null "> and disease_pid = #{diseasePid}</if> <if test="diseasePid != null "> and disease_pid = #{diseasePid}</if>
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if> <if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
<if test="result != null "> and result = #{result}</if> <if test="result != null "> and result = #{result}</if>
<if test="treatDay != null "> and treat_day = #{treatDay}</if> <if test="treatDay != null "> and treat_day = #{treatDay}</if>
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if> <if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
${params.dataScope}
</where> </where>
ORDER BY datetime DESC ORDER BY datetime DESC
<choose> <choose>
@@ -90,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sheepfoldId != null">sheepfold_id,</if> <if test="sheepfoldId != null">sheepfold_id,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treatId != null">#{treatId},</if> <if test="treatId != null">#{treatId},</if>
@@ -107,6 +121,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sheepfoldId != null">#{sheepfoldId},</if> <if test="sheepfoldId != null">#{sheepfoldId},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ds.sheepfold_name ds.sheepfold_name
FROM sw_disinfect sd FROM sw_disinfect sd
LEFT JOIN da_sheepfold ds ON ds.id = sd.sheepfold_id LEFT JOIN da_sheepfold ds ON ds.id = sd.sheepfold_id
WHERE 1 = 1 <where>1 = 1
<if test="sheepfoldId != null"> AND sd.sheepfold_id = #{sheepfoldId}</if> <if test="sheepfoldId != null"> AND sd.sheepfold_id = #{sheepfoldId}</if>
<if test="datetime != null"> AND sd.datetime = #{datetime}</if> <if test="datetime != null"> AND sd.datetime = #{datetime}</if>
<if test="technician != null and technician != ''"> AND sd.technician = #{technician}</if> <if test="technician != null and technician != ''"> AND sd.technician = #{technician}</if>
@@ -61,6 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND sm.name like concat('%',#{mediName},'%') AND sm.name like concat('%',#{mediName},'%')
) )
</if> </if>
${params.dataScope}
</where>
ORDER BY datetime DESC ORDER BY datetime DESC
</select> </select>
@@ -72,12 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id">
insert into sw_disinfect insert into sw_disinfect
(sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time) (sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time, user_id,dept_id)
values values
<foreach collection="list" item="d" separator=","> <foreach collection="list" item="d" separator=",">
(#{d.sheepfoldId}, #{d.datetime}, #{d.technician}, #{d.way}, (#{d.sheepfoldId}, #{d.datetime}, #{d.technician}, #{d.way},
#{d.usageId}, #{d.ratio}, #{d.comment}, #{d.usageId}, #{d.ratio}, #{d.comment},
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime}) #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
</foreach> </foreach>
</insert> </insert>

View File

@@ -50,9 +50,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if> <if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="technical != null and technical != ''"> and technical = #{technical}</if> <if test="technical != null and technical != ''"> and technical = #{technical}</if>
${params.dataScope}
</where> </where>
<!-- 基准排序:日期永远第一序,降序 --> <!-- 基准排序:日期永远第一序,降序 -->
ORDER BY datetime DESC ORDER BY datetime DESC
@@ -72,13 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sw_health insert into sw_health
(sheep_id, usage_id, variety, sheep_type, gender, month_age, (sheep_id, usage_id, variety, sheep_type, gender, month_age,
parity, breed,datetime, technical, comment, parity, breed,datetime, technical, comment,
update_by, update_time, create_by, create_time) update_by, update_time, create_by, create_time,user_id,dept_id)
values values
<foreach collection="list" item="d" separator=","> <foreach collection="list" item="d" separator=",">
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType}, (#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime}, #{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
#{d.technical}, #{d.comment}, #{d.technical}, #{d.comment},
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime}) #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
</foreach> </foreach>
</insert> </insert>

View File

@@ -48,9 +48,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if> <if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="technical != null and technical != ''"> and technical = #{technical}</if> <if test="technical != null and technical != ''"> and technical = #{technical}</if>
${params.dataScope}
</where> </where>
<!-- 基准排序:日期永远第一序,降序 --> <!-- 基准排序:日期永远第一序,降序 -->
ORDER BY datetime DESC ORDER BY datetime DESC
@@ -70,13 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sw_immunity insert into sw_immunity
(sheep_id, usage_id, variety, sheep_type, gender, month_age, (sheep_id, usage_id, variety, sheep_type, gender, month_age,
parity, breed,datetime, technical, comment, parity, breed,datetime, technical, comment,
update_by, update_time, create_by, create_time) update_by, update_time, create_by, create_time,user_id,dept_id)
values values
<foreach collection="list" item="d" separator=","> <foreach collection="list" item="d" separator=",">
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType}, (#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime}, #{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
#{d.technical}, #{d.comment}, #{d.technical}, #{d.comment},
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime}) #{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
</foreach> </foreach>
</insert> </insert>

View File

@@ -54,6 +54,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="quarItem != null "> and quar_item = #{quarItem}</if> <if test="quarItem != null "> and quar_item = #{quarItem}</if>
<if test="sampleType != null "> and sample_type = #{sampleType}</if> <if test="sampleType != null "> and sample_type = #{sampleType}</if>
<if test="sampler != null and sampler != ''"> and sampler like concat('%',#{sampler},'%') </if> <if test="sampler != null and sampler != ''"> and sampler like concat('%',#{sampler},'%') </if>
@@ -61,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="result != null "> and result = #{result}</if> <if test="result != null "> and result = #{result}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
<if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if> <if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if>
${params.dataScope}
</where> </where>
ORDER BY datetime DESC ORDER BY datetime DESC
<choose> <choose>
@@ -102,7 +113,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_by, update_by,
update_time, update_time,
create_by, create_by,
create_time create_time,
user_id,
dept_id
) )
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
@@ -123,7 +136,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.updateBy}, #{item.updateBy},
#{item.updateTime}, #{item.updateTime},
#{item.createBy}, #{item.createBy},
#{item.createTime} #{item.createTime},
#{item.userId},
#{item.deptId}
) )
</foreach> </foreach>
</insert> </insert>

View File

@@ -73,6 +73,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sheepNo != null and sheepNo != ''"> <if test="sheepNo != null and sheepNo != ''">
AND bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%') AND bs.manage_tags LIKE CONCAT('%', #{sheepNo}, '%')
</if> </if>
<if test="sheepNos != null and sheepNos.length > 0">
AND (
<foreach collection="sheepNos" item="item" separator=" OR " open="" close="">
bs.manage_tags LIKE CONCAT('%', #{item}, '%')
</foreach>
)
</if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<!-- 4. 使用时间区间 --> <!-- 4. 使用时间区间 -->
<if test="params.beginUseTime != null and params.endUseTime != null"> <if test="params.beginUseTime != null and params.endUseTime != null">
@@ -93,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND sm.name LIKE CONCAT('%', #{name}, '%') AND sm.name LIKE CONCAT('%', #{name}, '%')
) )
</if> </if>
${params.dataScope}
</where> </where>
ORDER BY smu.datetime DESC ORDER BY smu.datetime DESC
</select> </select>
@@ -144,6 +163,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if> <if test="name != null">#{name},</if>
@@ -155,6 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>

View File

@@ -62,11 +62,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
) )
</if> </if>
<!-- 全部羊多耳号查询(母羊或公羊匹配即可) -->
<if test="allEarNumbers != null and allEarNumbers.size() > 0">
AND (
bs.manage_tags IN
<foreach collection="allEarNumbers" item="earNumber" open="(" separator="," close=")">
#{earNumber}
</foreach>
)
</if>
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if> <if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if> <if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
<if test="status != null and status !=''"> and status = #{status}</if> <if test="status != null and status !=''"> and status = #{status}</if>
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if> <if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
${params.dataScope}
</where> </where>
ORDER BY datetime DESC ORDER BY datetime DESC
<choose> <choose>
@@ -110,6 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="userId != null">#{user_id},</if>
<if test="deptId != null">#{dept_id},</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="diagId != null">#{diagId},</if> <if test="diagId != null">#{diagId},</if>
@@ -133,6 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>
@@ -141,14 +157,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(diag_id, sheep_id, variety, sheep_type, month_age, gender, (diag_id, sheep_id, variety, sheep_type, month_age, gender,
parity, breed, lact_day, gest_day, datetime, parity, breed, lact_day, gest_day, datetime,
disease_id, disease_pid, veterinary, usage_id,status , disease_id, disease_pid, veterinary, usage_id,status ,
comment, update_by, update_time, create_by, create_time) comment, update_by, update_time, create_by, create_time, user_id, dept_id)
values values
<foreach collection="list" item="t" separator=","> <foreach collection="list" item="t" separator=",">
(#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType}, (#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType},
#{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed}, #{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed},
#{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId}, #{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId},
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment}, #{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment},
#{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime}) #{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime},#{t.userId},#{t.deptId})
</foreach> </foreach>
</insert> </insert>

View File

@@ -0,0 +1,33 @@
<?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">
<mapper namespace="com.zhyc.module.common.mapper.DeptMapper">
<resultMap type="Dept" id="DeptResult">
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="parentId" column="parent_id" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
</resultMap>
<select id="selectTopSecondLevelDept" resultMap="DeptResult" parameterType="Long">
SELECT d2.*
FROM sys_dept d1
LEFT JOIN sys_dept d2
ON d2.dept_id = CASE
WHEN d1.ancestors = '0' OR d1.parent_id = 0 THEN d1.dept_id
-- 二级部门逗号只出现1次返回自身ID
WHEN LENGTH(d1.ancestors) - LENGTH(REPLACE(d1.ancestors, ',', '')) = 1
THEN d1.dept_id
-- 三级及以上取第3个值索引2即二级部门ID
ELSE CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(d1.ancestors, ',', 3), ',', -1) AS UNSIGNED)
END
WHERE d1.dept_id = #{deptId}
AND d2.dept_id IS NOT NULL
</select>
</mapper>

View File

@@ -12,14 +12,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<select id="getUserListByCode" resultMap="UserResult"> <select id="getUserListByCode" resultMap="UserResult">
SELECT u.user_id, nick_name , post_name , post_code <choose>
FROM sys_role r <!-- deptId = 0查询所有用户不限制部门 -->
JOIN sys_user_role ur ON r.role_id = ur.role_id <when test="deptId == 0">
JOIN sys_user u ON ur.user_id = u.user_id SELECT DISTINCT u.user_id, u.nick_name, p.post_name, p.post_code
FROM sys_user u
JOIN sys_user_post up ON u.user_id = up.user_id JOIN sys_user_post up ON u.user_id = up.user_id
JOIN sys_post p ON up.post_id = p.post_id JOIN sys_post p ON up.post_id = p.post_id
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%') WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
AND r.status = 0 and r.del_flag = 0; AND u.status = 0
</select> AND u.del_flag = 0
</when>
<!-- deptId != 0递归查询该部门及所有子部门 -->
<otherwise>
WITH RECURSIVE dept_tree AS (
SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId}
UNION ALL
SELECT d.dept_id
FROM sys_dept d
INNER JOIN dept_tree dt ON d.parent_id = dt.dept_id
)
SELECT DISTINCT u.user_id, u.nick_name, p.post_name, p.post_code
FROM dept_tree dt
JOIN sys_user u ON u.dept_id = dt.dept_id
JOIN sys_user_post up ON u.user_id = up.user_id
JOIN sys_post p ON up.post_id = p.post_id
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
AND u.status = 0
AND u.del_flag = 0
</otherwise>
</choose>
</select>
</mapper> </mapper>

View File

@@ -29,7 +29,7 @@
<result property="matingDate" column="mating_date" /> <result property="matingDate" column="mating_date" />
<result property="expectedDate" column="expected_date" /> <result property="expectedDate" column="expected_date" />
<result property="lastEventDate" column="last_event_date" /> <result property="lastEventDate" column="last_event_date" />
<result property="ranchName" column="ranch" /> <result property="ranchName" column="sysRanch" />
<result property="daysAfterMating" column="days_after_mating" /> <result property="daysAfterMating" column="days_after_mating" />
</resultMap> </resultMap>
@@ -54,7 +54,7 @@
sf.breed, sf.breed,
sf.expected_date, sf.expected_date,
sf.lambing_date as last_event_date, sf.lambing_date as last_event_date,
sf.dr_ranch as ranch, sf.dr_ranch as sysRanch,
-- 关联配种信息 -- 关联配种信息
ram_sf.bs_manage_tags as father_manage_tags, ram_sf.bs_manage_tags as father_manage_tags,
ram_sf.variety as father_variety, ram_sf.variety as father_variety,

View File

@@ -1,7 +1,9 @@
package com.zhyc.system.mapper; package com.zhyc.system.mapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.zhyc.common.core.domain.entity.SysRanch;
import org.apache.ibatis.annotations.*;
import com.zhyc.common.core.domain.entity.SysDept; import com.zhyc.common.core.domain.entity.SysDept;
/** /**
@@ -115,4 +117,22 @@ public interface SysDeptMapper
* @return 结果 * @return 结果
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
@Insert("insert into da_ranch(ranch) values(#{ranch})")
@Options(useGeneratedKeys = true, keyProperty = "id")
public void insertRanch(SysRanch r);
@Insert("insert into sys_dept_ranch(dept_id,ranch_id) values(#{deptId},#{ranchId})")
void insertRanchDept(@Param("deptId") Long deptId, @Param("ranchId")Long ranchId);
@Select("select * from da_ranch where ranch = #{ranchName}")
SysRanch checkRanchExist(String ranchName);
@Select("select ranch_id from sys_dept_ranch where dept_id = #{deptId}")
Long selectSysRanchDeptById(@Param("deptId") Long deptId);
@Delete("delete from sys_dept_ranch where dept_id=#{deptId}")
void deleteSysRanchDeptById(Long deptId);
@Delete("delete from da_ranch where id= #{ranchId}")
void deleteRanchById(Long ranchId);
} }

View File

@@ -91,6 +91,8 @@ public interface ISysDeptService
*/ */
public boolean checkDeptNameUnique(SysDept dept); public boolean checkDeptNameUnique(SysDept dept);
boolean checkRanchName(SysDept dept);
/** /**
* 校验部门是否有数据权限 * 校验部门是否有数据权限
* *
@@ -121,4 +123,6 @@ public interface ISysDeptService
* @return 结果 * @return 结果
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
} }

View File

@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.zhyc.common.core.domain.entity.SysRanch;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.common.annotation.DataScope; import com.zhyc.common.annotation.DataScope;
@@ -20,6 +22,7 @@ import com.zhyc.common.utils.spring.SpringUtils;
import com.zhyc.system.mapper.SysDeptMapper; import com.zhyc.system.mapper.SysDeptMapper;
import com.zhyc.system.mapper.SysRoleMapper; import com.zhyc.system.mapper.SysRoleMapper;
import com.zhyc.system.service.ISysDeptService; import com.zhyc.system.service.ISysDeptService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 部门管理 服务实现 * 部门管理 服务实现
@@ -182,6 +185,18 @@ public class SysDeptServiceImpl implements ISysDeptService
return UserConstants.UNIQUE; return UserConstants.UNIQUE;
} }
@Override
public boolean checkRanchName(SysDept dept) {
if (!StringUtils.isNull(dept.getRanchName())){
SysRanch ranch = deptMapper.checkRanchExist(dept.getRanchName());
if (ranch!=null){
return false;
}
}
return true;
}
/** /**
* 校验部门是否有数据权限 * 校验部门是否有数据权限
* *
@@ -209,6 +224,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int insertDept(SysDept dept) public int insertDept(SysDept dept)
{ {
SysDept info = deptMapper.selectDeptById(dept.getParentId()); SysDept info = deptMapper.selectDeptById(dept.getParentId());
@@ -218,7 +234,15 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增"); throw new ServiceException("部门停用,不允许新增");
} }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept); int i = deptMapper.insertDept(dept);
if (dept.getRanchName()!=null){
SysRanch sysRanch = new SysRanch();
sysRanch.setRanch(dept.getRanchName());
deptMapper.insertRanch(sysRanch);
deptMapper.insertRanchDept(dept.getDeptId(), sysRanch.getId());
}
return i;
} }
/** /**
@@ -290,6 +314,9 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override @Override
public int deleteDeptById(Long deptId) public int deleteDeptById(Long deptId)
{ {
Long ranchId=deptMapper.selectSysRanchDeptById(deptId);
deptMapper.deleteSysRanchDeptById(deptId);
deptMapper.deleteRanchById(ranchId);
return deptMapper.deleteDeptById(deptId); return deptMapper.deleteDeptById(deptId);
} }

View File

@@ -20,13 +20,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="ranchName" column="ranch_name"/>
</resultMap> </resultMap>
<!-- 基础字段添加牧场信息 -->
<sql id="selectDeptVo"> <sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num,
d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by,
d.create_time, d.update_by, d.update_time,
r.ranch ranch_name
from sys_dept d from sys_dept d
left join sys_dept_ranch dr on d.dept_id = dr.dept_id
left join da_ranch r on dr.ranch_id = r.id
</sql> </sql>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where d.del_flag = '0' where d.del_flag = '0'
@@ -87,7 +96,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select> </select>
<insert id="insertDept" parameterType="SysDept">
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dept( insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if> <if test="parentId != null and parentId != 0">parent_id,</if>