根据岗位编号查询用户,以及生物安全模块的数据分离userId,deptId字段新增修改
This commit is contained in:
@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope
|
||||
|
||||
@@ -46,6 +46,7 @@ public class BasSheepController extends BaseController {
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
//查询耳号列表
|
||||
@GetMapping("/earNumbers")
|
||||
public AjaxResult searchEarNumbers(@RequestParam("query") String query) {
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.base.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.mapper.BasSheepMapper;
|
||||
@@ -51,6 +53,7 @@ public class BasSheepServiceImpl implements IBasSheepService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "b", userAlias = "b")
|
||||
public List<String> searchEarNumbers(String query) {
|
||||
return basSheepMapper.searchEarNumbers(query);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ public class DewormController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Deworm deworm)
|
||||
{
|
||||
System.out.println(deworm);
|
||||
deworm.setDeptId(getDeptId());
|
||||
deworm.setUserId(getUserId());
|
||||
return toAjax(dewormService.insertDeworm(deworm));
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ public class DiagnosisController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Diagnosis diagnosis)
|
||||
{
|
||||
diagnosis.setDeptId(getDeptId());
|
||||
diagnosis.setUserId(getUserId());
|
||||
return toAjax(diagnosisService.insertDiagnosis(diagnosis));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ public class DisinfectController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Disinfect disinfect)
|
||||
{
|
||||
disinfect.setDeptId(getDeptId());
|
||||
disinfect.setUserId(getUserId());
|
||||
return toAjax(disinfectService.insertDisinfect(disinfect));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ public class HealthController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Health health)
|
||||
{
|
||||
health.setDeptId(getDeptId());
|
||||
health.setUserId(getUserId());
|
||||
return toAjax(healthService.insertHealth(health));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ public class ImmunityController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Immunity immunity)
|
||||
{
|
||||
immunity.setDeptId(getDeptId());
|
||||
immunity.setUserId(getUserId());
|
||||
return toAjax(immunityService.insertImmunity(immunity));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ public class QuarantineReportController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody QuarantineReport quarantineReport)
|
||||
{
|
||||
quarantineReport.setDeptId(getDeptId());
|
||||
quarantineReport.setUserId(getUserId());
|
||||
return toAjax(quarantineReportService.insertQuarantineReport(quarantineReport));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ public class SwMedicineUsageController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SwMedicineUsage swMedicineUsage)
|
||||
{
|
||||
swMedicineUsage.setDeptId(getDeptId());
|
||||
swMedicineUsage.setUserId(getUserId());
|
||||
return toAjax(swMedicineUsageService.insertSwMedicineUsage(swMedicineUsage));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ public class TreatmentController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Treatment treatment)
|
||||
{
|
||||
treatment.setDeptId(getDeptId());
|
||||
treatment.setUserId(getUserId());
|
||||
return toAjax(treatmentService.insertTreatment(treatment));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ public class Deworm extends BaseEntity
|
||||
@Excel(name = "胎次")
|
||||
private Long parity;
|
||||
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 药品使用记录 */
|
||||
@Excel(name = "药品使用记录")
|
||||
@@ -81,4 +82,5 @@ public class Deworm extends BaseEntity
|
||||
// 排序查询
|
||||
private String orderByColumn;
|
||||
private String isAsc;
|
||||
|
||||
}
|
||||
|
||||
@@ -106,6 +106,9 @@ public class Diagnosis extends BaseEntity
|
||||
private String orderByColumn;
|
||||
private String isAsc;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
if (gender != null && !gender.trim().isEmpty()) {
|
||||
|
||||
@@ -61,6 +61,9 @@ public class Disinfect extends BaseEntity
|
||||
/** 药品名称用于查询*/
|
||||
private String mediName;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@ public class Health extends BaseEntity
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ public class Immunity extends BaseEntity
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
|
||||
@@ -98,6 +98,9 @@ public class QuarantineReport extends BaseEntity
|
||||
@Excel(name = "备注")
|
||||
private String comment;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
this.genderName = Gender.getDescByCode(Integer.valueOf(gender));
|
||||
|
||||
@@ -53,6 +53,9 @@ public class SwMedicineUsage extends BaseEntity
|
||||
@Excel(name = "使用类型",width = 20, needMerge = true)
|
||||
private String useType;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
/** 药品使用记录详情信息 */
|
||||
@Excel
|
||||
private List<SwMedicineUsageDetails> swMedicineUsageDetailsList;
|
||||
|
||||
@@ -104,6 +104,9 @@ public class Treatment extends BaseEntity
|
||||
@Excel(name = "药品使用记录id")
|
||||
private Integer usageId;
|
||||
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
|
||||
// 药品使用
|
||||
private List<SwMedicineUsageDetails> usageDetails;
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -58,6 +60,7 @@ public class DewormServiceImpl implements IDewormService
|
||||
* @return 驱虫
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
public List<Deworm> selectDewormList(Deworm deworm)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
@@ -60,6 +61,7 @@ public class DiagnosisServiceImpl implements IDiagnosisService
|
||||
* @return 诊疗结果
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "sd", userAlias = "sd")
|
||||
public List<Diagnosis> selectDiagnosisList(Diagnosis diagnosis)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -59,6 +61,7 @@ public class DisinfectServiceImpl implements IDisinfectService
|
||||
* @return 消毒记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "sd", userAlias = "sd")
|
||||
public List<Disinfect> selectDisinfectList(Disinfect disinfect)
|
||||
{
|
||||
return disinfectMapper.selectDisinfectList(disinfect);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -62,6 +63,7 @@ public class HealthServiceImpl implements IHealthService
|
||||
* @return 保健
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
public List<Health> selectHealthList(Health health)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -61,6 +63,7 @@ public class ImmunityServiceImpl implements IImmunityService
|
||||
* @return 免疫
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "s", userAlias = "s")
|
||||
public List<Immunity> selectImmunityList(Immunity immunity)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.module.biosafety.domain.QuarantineItems;
|
||||
import com.zhyc.module.biosafety.mapper.QuarantineItemsMapper;
|
||||
import com.zhyc.module.biosafety.service.IQuarantineItemsService;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -46,6 +48,7 @@ public class QuarantineReportServiceImpl implements IQuarantineReportService
|
||||
* @return 检疫记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "sqr", userAlias = "sqr")
|
||||
public List<QuarantineReport> selectQuarantineReportList(QuarantineReport quarantineReport)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.module.biosafety.service.ISwMedicineUsageService;
|
||||
@@ -44,6 +46,7 @@ public class SwMedicineUsageServiceImpl implements ISwMedicineUsageService
|
||||
* @return 药品使用记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "smu", userAlias = "smu")
|
||||
public List<SwMedicineUsage> selectSwMedicineUsageList(SwMedicineUsage swMedicineUsage)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zhyc.module.biosafety.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.zhyc.common.utils.DateUtils;
|
||||
import com.zhyc.common.utils.SecurityUtils;
|
||||
import com.zhyc.common.utils.bean.BeanUtils;
|
||||
@@ -65,6 +67,7 @@ public class TreatmentServiceImpl implements ITreatmentService
|
||||
* @return 治疗记录
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "t", userAlias = "t")
|
||||
public List<Treatment> selectTreatmentList(Treatment treatment)
|
||||
{
|
||||
String[] sheepNos = null;
|
||||
|
||||
@@ -26,7 +26,9 @@ public class UserPostController {
|
||||
// 根据岗位编码获取用户
|
||||
@GetMapping("/getUser")
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhyc.module.common.domain;
|
||||
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -8,7 +9,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Post {
|
||||
public class Post extends BaseEntity {
|
||||
|
||||
/** 岗位序号 */
|
||||
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhyc.module.common.domain;
|
||||
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -7,9 +8,10 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User {
|
||||
public class User extends BaseEntity {
|
||||
// 用户id
|
||||
private String userId;
|
||||
private Long userId;
|
||||
private Long deptId;
|
||||
// 用户名
|
||||
private String nickName;
|
||||
// 岗位名称
|
||||
@@ -17,4 +19,5 @@ public class User {
|
||||
// 岗位编码
|
||||
private String postCode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -8,5 +8,5 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
|
||||
List<User> getUserListByCode(String postCode);
|
||||
List<User> getUserListByCode(User user);
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ import com.zhyc.module.common.domain.User;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
List<User> getUserListByCode(String postCode);
|
||||
List<User> getUserListByCode(User postCode);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
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.mapper.DeptMapper;
|
||||
import com.zhyc.module.common.mapper.UserMapper;
|
||||
import com.zhyc.module.common.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -12,9 +16,16 @@ import java.util.List;
|
||||
public class UserPostServiceImpl implements UserService {
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@Autowired
|
||||
DeptMapper deptMapper;
|
||||
|
||||
@Override
|
||||
public List<User> getUserListByCode(String postCode) {
|
||||
return userMapper.getUserListByCode(postCode);
|
||||
public List<User> getUserListByCode(User user) {
|
||||
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
|
||||
Dept secondLevel = deptMapper.selectTopSecondLevelDept(deptId);
|
||||
user.setDeptId(secondLevel.getDeptId());
|
||||
System.out.println(secondLevel);
|
||||
return userMapper.getUserListByCode(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,9 +150,12 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT manage_tags
|
||||
FROM bas_sheep
|
||||
WHERE manage_tags LIKE CONCAT(#{query}, '%')
|
||||
FROM bas_sheep b
|
||||
<where>
|
||||
manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND is_delete = 0
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER by manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
@@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and datetime between #{params.beginDatetime} and #{params.endDatetime}
|
||||
</if>
|
||||
<if test="technical != null and technical != ''">and technical = #{technical}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
@@ -78,13 +79,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_deworm
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
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
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{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>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="treatDay != null "> and treat_day = #{treatDay}</if>
|
||||
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -101,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="treatId != null">#{treatId},</if>
|
||||
@@ -118,6 +121,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ds.sheepfold_name
|
||||
FROM sw_disinfect sd
|
||||
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="datetime != null"> AND sd.datetime = #{datetime}</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},'%')
|
||||
)
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
|
||||
</select>
|
||||
@@ -72,12 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id">
|
||||
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
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepfoldId}, #{d.datetime}, #{d.technician}, #{d.way},
|
||||
#{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>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</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>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
ORDER BY datetime DESC
|
||||
@@ -81,13 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_health
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
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
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{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>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</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>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
ORDER BY datetime DESC
|
||||
@@ -79,13 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_immunity
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
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
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{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>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -112,7 +113,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update_by,
|
||||
update_time,
|
||||
create_by,
|
||||
create_time
|
||||
create_time,
|
||||
user_id,
|
||||
dept_id
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
@@ -133,7 +136,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.createBy},
|
||||
#{item.createTime}
|
||||
#{item.createTime},
|
||||
#{item.userId},
|
||||
#{item.deptId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -111,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND sm.name LIKE CONCAT('%', #{name}, '%')
|
||||
)
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY smu.datetime DESC
|
||||
</select>
|
||||
@@ -162,6 +163,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
@@ -173,6 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
|
||||
<if test="status != null and status !=''"> and status = #{status}</if>
|
||||
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -121,6 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">#{user_id},</if>
|
||||
<if test="deptId != null">#{dept_id},</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="diagId != null">#{diagId},</if>
|
||||
@@ -144,6 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -152,14 +157,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
(diag_id, sheep_id, variety, sheep_type, month_age, gender,
|
||||
parity, breed, lact_day, gest_day, datetime,
|
||||
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
|
||||
<foreach collection="list" item="t" separator=",">
|
||||
(#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType},
|
||||
#{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed},
|
||||
#{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId},
|
||||
#{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>
|
||||
</insert>
|
||||
|
||||
|
||||
33
zhyc-module/src/main/resources/mapper/common/DeptMapper.xml
Normal file
33
zhyc-module/src/main/resources/mapper/common/DeptMapper.xml
Normal 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>
|
||||
@@ -12,14 +12,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<select id="getUserListByCode" resultMap="UserResult">
|
||||
SELECT u.user_id, nick_name , post_name , post_code
|
||||
FROM sys_role r
|
||||
JOIN sys_user_role ur ON r.role_id = ur.role_id
|
||||
JOIN sys_user u ON ur.user_id = u.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
|
||||
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
|
||||
AND r.status = 0 and r.del_flag = 0;
|
||||
</select>
|
||||
<choose>
|
||||
<!-- deptId = 0:查询所有用户,不限制部门 -->
|
||||
<when test="deptId == 0">
|
||||
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_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
|
||||
</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>
|
||||
Reference in New Issue
Block a user