555
Jinquan_Ou
2023-04-06 b4754ea670156f7f799311a9fdc9b3d380982fcb
555
12个文件已修改
477 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEquipmentController.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/test/java/com/ruoyi/insertData.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZInfoUser.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfEvent.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/ZfEquipmentService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipmentServiceImpl.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
@@ -20,6 +20,7 @@
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
@@ -98,7 +99,6 @@
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        return AjaxResult.success(zInfoUserService.getById(userId));
    }
//
@@ -109,6 +109,9 @@
    @Log(title = "个人详细信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZInfoUser zInfoUser) {
        if (!Pattern.matches("^[\\d]+(?:,[\\d]+)*$",zInfoUser.getFamilyId())) {
            throw new RuntimeException("请输入只有数字和英文逗号的字符串,且数字和逗号必须交替出现");
        }
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        zInfoUser.setUserId(userId);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEquipmentController.java
@@ -1,9 +1,26 @@
package com.ruoyi.web.controller.zhang;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZfEquipment;
import com.ruoyi.service.ZfEquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
/**
 * <p>
@@ -15,7 +32,88 @@
 */
@RestController
@RequestMapping("/zfEquipment")
public class ZfEquipmentController {
@Slf4j
public class ZfEquipmentController extends BaseController {
    @Autowired
    private ZfEquipmentService zfEquipmentService;
    @GetMapping("/all")
    public AjaxResult listAll(ZfEquipment zfEquipment){
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return zfEquipmentService.selectEquipmentList(zfEquipment, pageNum, pageSize);
    }
    /**
     * 导出家庭设备记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:export')")
    @Log(title = "家庭设备记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZfEquipment zfEquipment)
    {
        List<ZfEquipment> list = zfEquipmentService.selectByCondition(zfEquipment);
        log.info("导出记录为:{}",list);
        ExcelUtil<ZfEquipment> util = new ExcelUtil<ZfEquipment>(ZfEquipment.class);
        util.exportExcel(response, list, "家庭设备记录数据");
    }
//
    /**
     * 导入家庭设备记录列表
     */
    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
    {
        return zfEquipmentService.importExcel(file);
    }
    /**
     * 获取家庭设备记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zfEquipmentService.getById(id));
    }
//
    /**
     * 新增家庭设备记录
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:add')")
    @Log(title = "家庭设备记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZfEquipment zfEquipment)
    {
        return toAjax(zfEquipmentService.addEquipment(zfEquipment));
    }
    /**
     * 修改家庭设备记录
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:edit')")
    @Log(title = "家庭设备记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZfEquipment zfEquipment)
    {
        return toAjax(zfEquipmentService.updateById(zfEquipment));
    }
//
    /**
     * 批量删除家庭设备记录
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:remove')")
    @Log(title = "家庭设备记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zfEquipmentService.removeByIds(Arrays.asList(ids)));
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java
@@ -7,6 +7,7 @@
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZfProperty;
@@ -39,6 +40,7 @@
    @GetMapping("/all")
    public AjaxResult  listAll(ZfProperty zfProperty){
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return zfPropertyService.selectPropertyList(zfProperty, pageNum, pageSize);
@@ -78,7 +80,6 @@
        return AjaxResult.error("导入数据失败");
    }
    /**
     * 获取家庭资产记录详细信息
ruoyi-admin/src/test/java/com/ruoyi/insertData.java
@@ -1,8 +1,10 @@
package com.ruoyi;
import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.domain.ZfEquipment;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.service.ZfDoctorService;
import com.ruoyi.service.ZfEquipmentService;
import com.ruoyi.service.ZfEventService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +28,9 @@
    @Autowired
    private ZfDoctorService zfDoctorService;
    @Autowired
    private ZfEquipmentService zfEquipmentService;
    @Test
    public void insert(){
@@ -73,8 +78,8 @@
            zfDoctor.setType(l1.get(count));
            zfDoctor.setSymptom(l2.get(count));
            zfDoctor.setDuration(l3.get(count));
            zfDoctor.setCMedical(l4.get(count));
            zfDoctor.setWMedical(l5.get(count));
            zfDoctor.setCmedical(l4.get(count));
            zfDoctor.setWmedical(l5.get(count));
            zfDoctor.setEffect(l6.get(count));
            zfDoctor.setSuitable(l7.get(count));
            zfDoctor.setRemark(l8.get(count));
@@ -84,4 +89,32 @@
        }
    }
    @Test
    void insertEquipment(){
        List<String> l1 = Arrays.asList("电视", "电冰箱","电脑");
        List<String> l2 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08");
        List<String> l3 = Arrays.asList("张三", "李四", "王五");
        List<String> l4 = Arrays.asList("夏普液晶电视", "西门子电冰箱", "苹果电脑");
        List<String> l5 = Arrays.asList("客厅", "厨房", "卧室");
        List<String> l6 = Arrays.asList("4k超高清", "双开门", "M2芯片");
        ZfEquipment zfEquipment=null;
        int count=0;
        for (int i = 0; i < 200; i++) {
            count=count%3;
            zfEquipment=new ZfEquipment();
           zfEquipment.setName(l1.get(count));
           zfEquipment.setBuyer(l3.get(count));
           zfEquipment.setContent(l4.get(count));
           zfEquipment.setLocation(l5.get(count));
           zfEquipment.setRemark(l6.get(count));
           zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg");
            count++;
            zfEquipmentService.save(zfEquipment);
        }
    }
}
zhang-content/src/main/java/com/ruoyi/domain/ZInfoUser.java
@@ -156,7 +156,10 @@
     */
    private String url;
    /**
     * 家庭id
     */
    private String familyId;
}
zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java
@@ -3,8 +3,13 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
 * <p>
@@ -15,110 +20,58 @@
 * @since 2023-03-12
 */
@TableName("zf_equipment")
@Data
public class ZfEquipment implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    private Long id;
    /**
     * 设备名称
     */
    @Excel(name = "设备名称")
    private String name;
    /**
     * 记录时间
     */
    private LocalDateTime createDate;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd")
    private Date createDate;
    /**
     * 购买人
     */
    @Excel(name = "购买人")
    private String buyer;
    /**
     * 事项内容
     */
    @Excel(name = "事项内容")
    private String content;
    /**
     * 存放地点
     */
    @Excel(name = "存放地点")
    private String location;
    /**
     * 备注
     */
    @Excel(name = "备注")
    private String remark;
    /**
     * 家庭id
     */
    @Excel(name = "家庭id")
    private String familyId;
    public Integer getId() {
        return id;
    }
    private String url;
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public LocalDateTime getCreateDate() {
        return createDate;
    }
    public void setCreateDate(LocalDateTime createDate) {
        this.createDate = createDate;
    }
    public String getBuyer() {
        return buyer;
    }
    public void setBuyer(String buyer) {
        this.buyer = buyer;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Override
    public String toString() {
        return "ZfEquipment{" +
        "id=" + id +
        ", name=" + name +
        ", createDate=" + createDate +
        ", buyer=" + buyer +
        ", content=" + content +
        ", location=" + location +
        ", remark=" + remark +
        "}";
    }
}
zhang-content/src/main/java/com/ruoyi/domain/ZfEvent.java
@@ -33,8 +33,8 @@
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd")
    private Date createTime;
    /**
@@ -63,4 +63,7 @@
    private String url;
    @Excel(name="家庭编号")
    private String familyId;
}
zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java
@@ -56,10 +56,16 @@
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd")
    private Date createTime;
    private String url;
    /**
     * 家庭id
     */
    @Excel(name="家庭编号")
    private String familyId;
}
zhang-content/src/main/java/com/ruoyi/service/ZfEquipmentService.java
@@ -2,7 +2,11 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.ZfEquipment;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
 * <p>
@@ -14,4 +18,12 @@
 */
public interface ZfEquipmentService extends IService<ZfEquipment> {
    AjaxResult selectEquipmentList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize);
    List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment);
    int addEquipment(ZfEquipment zfEquipment);
    AjaxResult importExcel(MultipartFile file);
}
zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java
@@ -4,15 +4,20 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.domain.ZfProperty;
import com.ruoyi.mapper.ZfPropertyMapper;
import com.ruoyi.service.IZfPropertyService;
import com.ruoyi.service.ZInfoUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
@@ -32,9 +37,13 @@
@Service
public class IZfPropertyServiceImpl extends ServiceImpl<ZfPropertyMapper, ZfProperty> implements IZfPropertyService {
    @Resource
    ZInfoUserService zInfoUserService;
    @Override
    public List<ZfProperty> selectByCondition(ZfProperty zfProperty) {
        LambdaQueryWrapper<ZfProperty> lambdaQueryWrapper = buildCondition(zfProperty);
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfProperty> lambdaQueryWrapper = buildCondition(zfProperty,familyIds);
        List<ZfProperty> list = list(lambdaQueryWrapper);
        log.info("返回的数据为:{}",list);
        return list;
@@ -52,14 +61,34 @@
        return lqw;
    }
    private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty,String familyIds) {
        LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfProperty::getFamilyId,familyId);
            }
        }else {
            lqw.eq(ZfProperty::getFamilyId,familyIds);
        }
        return lqw;
    }
    private String listFamilyIds(){
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
        zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId,userId);
        ZInfoUser zInfoUser = zInfoUserService.getOne(zInfoUserLambdaQueryWrapper);
        return zInfoUser.getFamilyId();
    }
    @Override
    public AjaxResult selectPropertyList(ZfProperty zfProperty,Integer pageNum,Integer pageSize) {
        LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty);
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty,familyIds);
        Page<ZfProperty> zfPropertyPage = new Page<>(pageNum,pageSize);
        Page<ZfProperty> pageResult = page(zfPropertyPage, lqw);
        HashMap<String, Object> data = MapUtils.getResult(pageResult);
        return AjaxResult.success(data);
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipmentServiceImpl.java
@@ -1,21 +1,143 @@
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfEquipment;
import com.ruoyi.domain.ZfEquipment;
import com.ruoyi.domain.ZfProperty;
import com.ruoyi.mapper.ZfEquipmentMapper;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfEquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
/**
 * <p>
 *  服务实现类
 * 服务实现类
 * </p>
 *
 * @author ojq
 * @since 2023-03-12
 */
@Service
@Slf4j
public class ZfEquipmentServiceImpl extends ServiceImpl<ZfEquipmentMapper, ZfEquipment> implements ZfEquipmentService {
    @Resource
    ZInfoUserService zInfoUserService;
    @Resource
    ZfEquipmentService zfEquipmentService;
    @Override
    public List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment) {
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, familyIds);
        List<ZfEquipment> list = list(lambdaQueryWrapper);
        log.info("返回的数据为:{}", list);
        return list;
    }
    @Override
    public int addEquipment(ZfEquipment zfEquipment) {
        String familyIds = listFamilyIds();
        boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                if (familyId.equals(zfEquipment.getFamilyId())) {
                    flag = true;
                }
            }
        } else {
            if (zfEquipment.getFamilyId().equals(familyIds)) {
                flag = true;
            }
        }
        if (flag) {
            boolean save = save(zfEquipment);
            return save ? 1 : 0;
        } else {
            throw new RuntimeException("你没有操作该家庭号为" + zfEquipment.getFamilyId() + "数据的权限");
        }
    }
    @Override
    @Transactional
    public AjaxResult importExcel(MultipartFile file) {
        ExcelUtil<ZfEquipment> util = new ExcelUtil<>(ZfEquipment.class);
        List<ZfEquipment> equipmentList = null;
        try {
            equipmentList = util.importExcel(file.getInputStream());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        log.info("资产列表为:{}", equipmentList);
        for (ZfEquipment zfEquipment : equipmentList) {
            zfEquipmentService.addEquipment(zfEquipment);
        }
        return AjaxResult.success("导入数据成功");
    }
    private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment) {
        LambdaQueryWrapper<ZfEquipment> lqw = new LambdaQueryWrapper<>();
        lqw.like(StringUtils.isNotEmpty(zfEquipment.getName()), ZfEquipment::getName, zfEquipment.getName());
        lqw.like(StringUtils.isNotEmpty(zfEquipment.getBuyer()), ZfEquipment::getBuyer, zfEquipment.getBuyer());
        lqw.like(StringUtils.isNotEmpty(zfEquipment.getContent()), ZfEquipment::getContent, zfEquipment.getContent());
        lqw.like(StringUtils.isNotEmpty(zfEquipment.getLocation()), ZfEquipment::getLocation, zfEquipment.getLocation());
        lqw.like(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark());
        lqw.like(zfEquipment.getCreateDate() != null, ZfEquipment::getCreateDate, zfEquipment.getCreateDate());
        return lqw;
    }
    private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment, String familyIds) {
        LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfEquipment::getFamilyId, familyId);
            }
        } else {
            lqw.eq(ZfEquipment::getFamilyId, familyIds);
        }
        return lqw;
    }
    private String listFamilyIds() {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
        zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId);
        ZInfoUser zInfoUser = zInfoUserService.getOne(zInfoUserLambdaQueryWrapper);
        return zInfoUser.getFamilyId();
    }
    @Override
    public AjaxResult selectEquipmentList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize) {
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, familyIds);
        Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNum, pageSize);
        Page<ZfEquipment> pageResult = page(zfEquipmentPage, lqw);
        HashMap<String, Object> data = MapUtils.getResult(pageResult);
        return AjaxResult.success(data);
    }
}
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
@@ -5,16 +5,19 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.mapper.ZfEventMapper;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfEventService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@@ -30,9 +33,23 @@
@Service
public class ZfEventServiceImpl extends ServiceImpl<ZfEventMapper, ZfEvent> implements ZfEventService {
    @Resource
    ZInfoUserService zInfoUserService;
    private String listFamilyIds(){
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
        zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId,userId);
        ZInfoUser zInfoUser = zInfoUserService.getOne(zInfoUserLambdaQueryWrapper);
        return zInfoUser.getFamilyId();
    }
    @Override
    public AjaxResult selectEventList(ZfEvent zfEvent, Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent);
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent,familyIds);
        Page<ZfEvent> ZfEventPage = new Page<>(pageNum,pageSize);
        Page<ZfEvent> pageResult = page(ZfEventPage, lqw);
@@ -40,11 +57,13 @@
        HashMap<String, Object> data = MapUtils.getResult(pageResult);
        return AjaxResult.success(data);
    }
    @Override
    public List<ZfEvent> selectByCondition(ZfEvent zfEvent) {
        LambdaQueryWrapper<ZfEvent> lambdaQueryWrapper = buildCondition(zfEvent);
        List<ZfEvent> list = list(lambdaQueryWrapper);
        String familyIds = listFamilyIds();
        LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent,familyIds);
        List<ZfEvent> list = list(lqw);
        log.info("返回的数据为:{}",list);
        return list;
    }
@@ -59,4 +78,17 @@
        return lqw;
    }
    private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent, String familyIds) {
        LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfEvent::getFamilyId,familyId);
            }
        }else {
            lqw.eq(ZfEvent::getFamilyId,familyIds);
        }
        return lqw;
    }
}