根据岗位编号查询用户,以及生物安全模块的数据分离userId,deptId字段新增修改

This commit is contained in:
2026-01-29 23:28:24 +08:00
parent c9cefa3d33
commit 086cb43359
47 changed files with 237 additions and 35 deletions

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

@@ -46,6 +46,7 @@ public class BasSheepController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
//查询耳号列表
@GetMapping("/earNumbers") @GetMapping("/earNumbers")
public AjaxResult searchEarNumbers(@RequestParam("query") String query) { public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
try { try {

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;
@@ -51,6 +53,7 @@ public class BasSheepServiceImpl implements IBasSheepService
* @return * @return
*/ */
@Override @Override
@DataScope(deptAlias = "b", userAlias = "b")
public List<String> searchEarNumbers(String query) { public List<String> searchEarNumbers(String query) {
return basSheepMapper.searchEarNumbers(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

@@ -54,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 = "药品使用记录")
@@ -81,4 +82,5 @@ public class Deworm extends BaseEntity
// 排序查询 // 排序查询
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
} }

View File

@@ -106,6 +106,9 @@ public class Diagnosis extends BaseEntity
private String orderByColumn; private String orderByColumn;
private String isAsc; private String isAsc;
private Long userId;
private Long deptId;
public void setGender(String gender) { public void setGender(String gender) {
this.gender = gender; this.gender = gender;
if (gender != null && !gender.trim().isEmpty()) { if (gender != null && !gender.trim().isEmpty()) {

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

@@ -69,6 +69,9 @@ 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;

View File

@@ -78,6 +78,9 @@ 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;

View File

@@ -98,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

@@ -53,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

@@ -104,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,6 +46,7 @@ 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; 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;
@@ -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

@@ -150,9 +150,12 @@
<select id="searchEarNumbers" resultType="java.lang.String"> <select id="searchEarNumbers" resultType="java.lang.String">
SELECT DISTINCT manage_tags SELECT DISTINCT manage_tags
FROM bas_sheep FROM bas_sheep b
WHERE manage_tags LIKE CONCAT(#{query}, '%') <where>
manage_tags LIKE CONCAT(#{query}, '%')
AND is_delete = 0 AND is_delete = 0
${params.dataScope}
</where>
ORDER by manage_tags ORDER by manage_tags
LIMIT 50 LIMIT 50
</select> </select>

View File

@@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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>
<!-- 基准排序:日期永远第一序,降序 --> <!-- 基准排序:日期永远第一序,降序 -->
@@ -78,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

@@ -69,6 +69,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="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>
@@ -101,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>
@@ -118,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

@@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </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
@@ -81,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

@@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </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
@@ -79,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

@@ -71,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>
@@ -112,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=",">
@@ -133,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

@@ -111,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>
@@ -162,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>
@@ -173,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

@@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
@@ -121,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>
@@ -144,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>
@@ -152,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
JOIN sys_user_post up ON u.user_id = up.user_id FROM sys_user u
JOIN sys_post p ON up.post_id = p.post_id JOIN sys_user_post up ON u.user_id = up.user_id
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%') JOIN sys_post p ON up.post_id = p.post_id
AND r.status = 0 and r.del_flag = 0; WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
</select> AND u.status = 0
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>