From 8e93f63d7eab5c4f5d193763cbb2e81ea5476923 Mon Sep 17 00:00:00 2001
From: whywhyo <1511349576@qq.com>
Date: 星期日, 16 七月 2023 21:03:59 +0800
Subject: [PATCH] 559

---
 zhang-content/src/main/java/com/ruoyi/domain/ZfPetNote.java                     |    5 
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetServiceImpl.java        |  247 +++++++++++++++++++++++++++++------
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java   |   54 ++++---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java |    2 
 zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java               |    2 
 zhang-content/src/main/java/com/ruoyi/domain/ZExperience.java                   |    7 +
 zhang-content/src/main/java/com/ruoyi/service/ZfPetService.java                 |   16 ++
 zhang-content/src/main/java/com/ruoyi/domain/ZfPet.java                         |   32 ++++
 8 files changed, 292 insertions(+), 73 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java
index d923814..efa483d 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPetController.java
@@ -43,7 +43,7 @@
     public AjaxResult listAll(ZfPet zfPet){
         Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
         Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
-        return zfPetService.selectPetList(zfPet, pageNum, pageSize);
+        return zfPetService.selectDataList(zfPet, pageNum, pageSize);
     }
 
     /**
@@ -56,25 +56,26 @@
         util.exportExcel(response,list,"榄呭疇璁板綍瀵煎叆妯℃澘");
     }
 
+//    /**
+//     * 瀵煎嚭榄呭疇璁板綍鍒楄〃
+//     */
+////    @PreAuthorize("@ss.hasPermi('system:property:export')")
+//    @Log(title = "榄呭疇璁板綍", businessType = BusinessType.EXPORT)
+//    @PostMapping("/export")
+//    public void export(HttpServletResponse response, ZfPet zfPet)
+//    {
+//        List<ZfPet> list = zfPetService.selectByCondition(zfPet);
+//        log.info("瀵煎嚭璁板綍涓�:{}",list);
+//        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
+//        util.exportExcel(response, list, "榄呭疇璁板綍鏁版嵁");
+//    }
+
     /**
      * 瀵煎嚭榄呭疇璁板綍鍒楄〃
      */
 //    @PreAuthorize("@ss.hasPermi('system:property:export')")
     @Log(title = "榄呭疇璁板綍", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, ZfPet zfPet)
-    {
-        List<ZfPet> list = zfPetService.selectByCondition(zfPet);
-        log.info("瀵煎嚭璁板綍涓�:{}",list);
-        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
-        util.exportExcel(response, list, "榄呭疇璁板綍鏁版嵁");
-    }
-    /**
-     * 瀵煎嚭榄呭疇璁板綍鍒楄〃
-     */
-//    @PreAuthorize("@ss.hasPermi('system:property:export')")
-    @Log(title = "榄呭疇璁板綍", businessType = BusinessType.EXPORT)
-    @PostMapping("/export1/{ids}")
+    @PostMapping("/export/{ids}")
     public void export(HttpServletResponse response, @PathVariable Long[] ids)
     {
         List<ZfPet> list = zfPetService.selectByIds(ids);
@@ -90,14 +91,15 @@
     @PostMapping("/importData")
     public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
     {
-        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
-        List<ZfPet> eventList = util.importExcel(file.getInputStream());
-        log.info("榄呭疇鍒楄〃涓猴細{}",eventList);
-
-        if (zfPetService.saveBatch(eventList)) {
-            return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
-        }
-        return AjaxResult.error("瀵煎叆鏁版嵁澶辫触");
+//        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
+//        List<ZfPet> eventList = util.importExcel(file.getInputStream());
+//        log.info("榄呭疇鍒楄〃涓猴細{}",eventList);
+//
+//        if (zfPetService.saveBatch(eventList)) {
+//            return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
+//        }
+//        return AjaxResult.error("瀵煎叆鏁版嵁澶辫触");
+        return zfPetService.importExcel(file);
     }
 
     /**
@@ -118,7 +120,7 @@
     @PostMapping
     public AjaxResult add(@RequestBody ZfPet zfPet)
     {
-        return zfPetService.mySave(zfPet);
+        return zfPetService.addData(zfPet);
     }
 
     /**
@@ -129,7 +131,7 @@
     @PutMapping
     public AjaxResult edit(@RequestBody ZfPet zfPet)
     {
-        return toAjax(zfPetService.updateById(zfPet));
+        return zfPetService.updateData(zfPet);
     }
 //
     /**
@@ -140,7 +142,7 @@
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)
     {
-        return toAjax(zfPetService.removeByIds(Arrays.asList(ids)));
+        return zfPetService.deleteData(ids);
     }
 
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java b/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java
index cba08d4..4e20265 100644
--- a/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java
+++ b/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java
@@ -46,7 +46,7 @@
     public static final String DOCTOR_LIST_UPDATE="2031";
     public static final String DOCTOR_LIST_REMOVE="2032";
 
-    public static final String FAMILY_PET="2033";
+    public static final String FAMILY_PET_LIST="2033";
     public static final String FAMILY_PET_ADD="2034";
     public static final String FAMILY_PET_UPDATE="2035";
     public static final String FAMILY_PET_REMOVE="2036";
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZExperience.java b/zhang-content/src/main/java/com/ruoyi/domain/ZExperience.java
index 3ea8652..cd48c2e 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZExperience.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZExperience.java
@@ -51,6 +51,13 @@
     private Date startDate;
 
     /**
+     * 缁撴潫鏃ユ湡
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "缁撴潫鏃ユ湡", dateFormat = "yyyy-MM-dd")
+    private Date endDate;
+
+    /**
      * 璇佹槑浜哄悕瀛�
      */
     @Excel(name = "璇佹槑浜哄悕瀛�")
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfPet.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfPet.java
index fa80a5b..d320188 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZfPet.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfPet.java
@@ -1,6 +1,7 @@
 package com.ruoyi.domain;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -109,9 +110,38 @@
     @Excel(name = "鑳藉惉鎳傜殑鏂硅█")
     private String dialect;
 
-    private String url;
+    private Long familyId;
+
+    @TableField(exist = false)
+    private Integer ownData;
+
 
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date createTime;
 
+    /**
+     * 澶村儚
+     */
+    private String headPicture;
+
+    /**
+     * 鍏ㄨ韩鐓�
+     */
+    private String fullPicture;
+
+    //浠ヤ笅鏄富浜轰俊鎭�
+
+    @Excel(name = "涓讳汉鍚嶅瓧")
+    private String masterName;
+
+    @Excel(name = "涓讳汉璇佷欢鍙风爜")
+    private String masterIdNum;
+
+    @Excel(name = "涓讳汉鐢佃瘽鍙风爜")
+    private String phone;
+
+    @Excel(name = "涓讳汉鍦板潃")
+    private String masterAddress;
+
+
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfPetNote.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfPetNote.java
index 975ea29..2cd6bb7 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZfPetNote.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfPetNote.java
@@ -58,6 +58,7 @@
     /**
      * 鍒涘缓鏃堕棿
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date createTime;
 
     /**
@@ -70,15 +71,19 @@
 
 
     @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date happenStartTime;
 
     @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date happenEndTime;
 
     @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date remindStartTime;
 
     @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date remindEndTime;
 
 
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfPetService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfPetService.java
index e02b9dd..fec3a38 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZfPetService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfPetService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.domain.ZfPet;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -17,9 +18,20 @@
  */
 public interface ZfPetService extends IService<ZfPet> {
 
-    AjaxResult selectPetList(ZfPet zfPet, Integer pageNum, Integer pageSize);
+//    AjaxResult selectPetList(ZfPet zfPet, Integer pageNum, Integer pageSize);
 
+    AjaxResult selectDataList(ZfPet zfPet, Integer pageNum, Integer pageSize);
     List<ZfPet> selectByCondition(ZfPet zfPet);
     List<ZfPet> selectByIds(Long[] ids);
-    AjaxResult mySave(ZfPet zfPet);
+//    AjaxResult mySave(ZfPet zfPet);
+
+    AjaxResult importExcel(MultipartFile file);
+
+    AjaxResult addData(ZfPet zfPet);
+
+    AjaxResult updateData(ZfPet zfPet);
+
+    AjaxResult deleteData(Long[] ids);
+
+
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
index d3d0f14..e0f605e 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
@@ -354,7 +354,7 @@
         }
 
         List<ZAuthority> authority = zAuthorityService.getAuthority();
-        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
+        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(COLLECTION_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
         familyIdList.add(familyId);
 
         if (zfCollection.getFamilyId()!=null && !familyIdList.contains(zfCollection.getFamilyId())) {
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetServiceImpl.java
index 5d1639f..1a6014a 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetServiceImpl.java
@@ -9,13 +9,11 @@
 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.common.utils.uuid.IdUtils;
-import com.ruoyi.domain.ZInfoUser;
-import com.ruoyi.domain.ZfMaster;
-import com.ruoyi.domain.ZfEquipment;
-import com.ruoyi.domain.ZfPet;
-import com.ruoyi.domain.ZfProperty;
+import com.ruoyi.domain.*;
 import com.ruoyi.mapper.ZfPetMapper;
+import com.ruoyi.service.ZAuthorityService;
 import com.ruoyi.service.ZInfoUserService;
 import com.ruoyi.service.ZfMasterService;
 import com.ruoyi.service.ZfPetService;
@@ -24,11 +22,16 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
+import java.util.stream.Collectors;
+
+import static com.ruoyi.constant.MenuAuthority.*;
 
 /**
  * <p>
@@ -50,23 +53,77 @@
 
     @Autowired
     ZfPetService zfPetService;
+    
+    @Resource
+    ZAuthorityService zAuthorityService;
     @Override
-    public AjaxResult selectPetList(ZfPet zfPet, Integer pageNum, Integer pageSize) {
-        LambdaQueryWrapper<ZfPet> lqw = buildCondition(zfPet);
-        lqw.orderByDesc(ZfPet::getCreateTime);
-        Page<ZfPet> ZfPetPage = new Page<>(pageNum,pageSize);
-        Page<ZfPet> pageResult = page(ZfPetPage, lqw);
-        HashMap<String, Object> data = MapUtils.getResult(pageResult);
+    public AjaxResult selectDataList(ZfPet zfPet, Integer pageNum, Integer pageSize) {
+//        LambdaQueryWrapper<ZfPet> lqw = buildCondition(zfPet);
+//        lqw.orderByDesc(ZfPet::getCreateTime);
+//        Page<ZfPet> ZfPetPage = new Page<>(pageNum,pageSize);
+//        Page<ZfPet> pageResult = page(ZfPetPage, lqw);
+//        HashMap<String, Object> data = MapUtils.getResult(pageResult);
+//        return AjaxResult.success(data);
+
+        //瑕佹煡鑷繁瀹跺涵鐨�
+        ZInfoUser myself = zInfoUserService.getMyself();
+        Long familyId = myself.getFamilyId();
+        //涔熻鏌ュ埆浜烘巿鏉冪殑
+        List<ZAuthority> authority = zAuthorityService.getAuthority();
+        List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(FAMILY_PET_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
+        //鍔犱笂鑷繁瀹跺涵鐨刬d
+        idList.add(familyId);
+//        String familyIds = listFamilyIds();
+//        String secondFamilyAuthority = listSecondFamilyIds();
+        LambdaQueryWrapper<ZfPet> lqw = buildCondition(zfPet, idList);
+
+
+        Page<ZfPet> zfPetPage = new Page<>(pageNum, pageSize);
+        Page<ZfPet> pageResult = page(zfPetPage, lqw);
+
+        List<ZfPet> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+
+        List<ZfPet> dtoResult = markOwnData(familyId, beanRecords);
+
+        HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult);
         return AjaxResult.success(data);
     }
 
+    public List<ZfPet> markOwnData(Long familyId,List<ZfPet> beanRecords){
+        return beanRecords.stream().peek(
+                bean -> {
+                    if (bean.getFamilyId() == familyId) {
+                        bean.setOwnData(1);
+                    } else {
+                        bean.setOwnData(0);
+                    }
+                }
+        ).collect(Collectors.toList());
+    }
+
+
+    
+
     @Override
     public List<ZfPet> selectByCondition(ZfPet zfPet) {
-        LambdaQueryWrapper<ZfPet> lambdaQueryWrapper = buildCondition(zfPet);
-        lambdaQueryWrapper.orderByDesc(ZfPet::getCreateTime);
-        List<ZfPet> list = list(lambdaQueryWrapper);
-        log.info("杩斿洖鐨勬暟鎹负:{}",list);
-        return list;
+//        LambdaQueryWrapper<ZfPet> lambdaQueryWrapper = buildCondition(zfPet);
+//        lambdaQueryWrapper.orderByDesc(ZfPet::getCreateTime);
+//        List<ZfPet> list = list(lambdaQueryWrapper);
+//        log.info("杩斿洖鐨勬暟鎹负:{}",list);
+//        return list;
+        //瑕佹煡鑷繁瀹跺涵鐨�
+        ZInfoUser myself = zInfoUserService.getMyself();
+        Long familyId = myself.getFamilyId();
+        //涔熻鏌ュ埆浜烘巿鏉冪殑
+        List<ZAuthority> authority = zAuthorityService.getAuthority();
+        List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(FAMILY_PET_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
+        //鍔犱笂鑷繁瀹跺涵鐨刬d
+        idList.add(familyId);
+
+        LambdaQueryWrapper<ZfPet> lambdaQueryWrapper = buildCondition(zfPet, idList);
+        List<ZfPet> beanRecords = list(lambdaQueryWrapper);
+        log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecords);
+        return markOwnData(familyId, beanRecords);
     }
 
     @Override
@@ -80,44 +137,148 @@
     }
 
     @Override
-    @Transactional
-    public AjaxResult mySave(ZfPet zfPet) {
-        SysUser user = SecurityUtils.getLoginUser().getUser();
-        Long userId = user.getUserId();
+    public AjaxResult importExcel(MultipartFile file) {
+        ExcelUtil<ZfPet> util = new ExcelUtil<>(ZfPet.class);
+        List<ZfPet> dataList = null;
+        try {
+            dataList = util.importExcel(file.getInputStream());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        log.info("鏁版嵁鍒楄〃涓猴細{}", dataList);
 
-        String pid = IdUtils.fastSimpleUUID();
-        zfPet.setId(pid);
+        for (ZfPet zfPet : dataList) {
+            zfPetService.addData(zfPet);
+        }
+
+        return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
+    }
+
+    @Override
+    public AjaxResult addData(ZfPet zfPet) {
+        ZInfoUser myself = zInfoUserService.getMyself();
+        Long familyId = myself.getFamilyId();
+
+        if(familyId == null){
+            throw new RuntimeException("鎮ㄨ繕鏈姞鍏ヤ换浣曞搴�");
+        }
+
+        List<ZAuthority> authority = zAuthorityService.getAuthority();
+        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(FAMILY_PET_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
+        familyIdList.add(familyId);
+
+        if (zfPet.getFamilyId()!=null && !familyIdList.contains(zfPet.getFamilyId())) {
+            throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
+        }
+
+
+        if(zfPet.getFamilyId() == null){
+            //榛樿娣诲姞鑷繁瀹跺涵鐨勬暟鎹�
+            zfPet.setFamilyId(familyId);
+        }
 
         //鍒ゆ柇鏄惁鏈夐噸澶嶆暟鎹�
         LambdaQueryWrapper<ZfPet> lqw = uniqueCondition(zfPet);
         List<ZfPet> list = list(lqw);
+
         if(list.size()>0){
             throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
         }
 
-        //鍏堟煡鎵炬湰浜虹殑鏁版嵁
-        LambdaQueryWrapper<ZInfoUser> zInfoLqw = new LambdaQueryWrapper<>();
-        zInfoLqw.eq(ZInfoUser::getUserId,userId);
-        ZInfoUser master = zInfoUserService.getOne(zInfoLqw);
-
-        ZfMaster zfMaster = new ZfMaster();
-        zfMaster.setPetId(zfPet.getId());
-        zfMaster.setName(master.getNickName());
-        zfMaster.setCertificateType("韬唤璇�");
-        zfMaster.setCertificateNo(master.getIdNo());
-        zfMaster.setPhoneNo(master.getPhoneNumber());
-        zfMaster.setAddress(master.getAlwaysAddress());
-
-        zfMasterService.save(zfMaster);
-
-        zfPetService.save(zfPet);
-
-        return AjaxResult.success();
-
+        if (save(zfPet)) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
     }
+
+    @Override
+    public AjaxResult updateData(ZfPet zfPet) {
+        ZInfoUser myself = zInfoUserService.getMyself();
+        Long familyId = myself.getFamilyId();
+
+        //鍏堟牴鎹甶d鏌ヨ鍑烘暟鎹殑familyId锛岀湅鐪嬫湁娌℃湁鏉冮檺鎿嶄綔
+        Long dataFamilyId = getById(zfPet.getId()).getFamilyId();
+
+        List<ZAuthority> authority = zAuthorityService.getAuthority();
+        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(FAMILY_PET_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList());
+        familyIdList.add(familyId);
+
+        if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) {
+            throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
+        }
+
+        if(updateById(zfPet)){
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error();
+        }
+    }
+
+    @Override
+    public AjaxResult deleteData(Long[] ids) {
+        List<ZfPet> dataList = zfPetService.listByIds(Arrays.asList(ids));
+
+        ZInfoUser myself = zInfoUserService.getMyself();
+        Long familyId = myself.getFamilyId();
+
+        List<ZAuthority> authority = zAuthorityService.getAuthority();
+        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(FAMILY_PET_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList());
+        familyIdList.add(familyId);
+
+        for (ZfPet data : dataList) {
+            if (!familyIdList.contains(data.getFamilyId())){
+                throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
+            }
+        }
+
+        if (zfPetService.removeByIds(Arrays.asList(ids))) {
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error();
+        }
+    }
+
+//    @Override
+//    @Transactional
+//    public AjaxResult mySave(ZfPet zfPet) {
+//        SysUser user = SecurityUtils.getLoginUser().getUser();
+//        Long userId = user.getUserId();
+//
+//        String pid = IdUtils.fastSimpleUUID();
+//        zfPet.setId(pid);
+//
+//        //鍒ゆ柇鏄惁鏈夐噸澶嶆暟鎹�
+//        LambdaQueryWrapper<ZfPet> lqw = uniqueCondition(zfPet);
+//        List<ZfPet> list = list(lqw);
+//        if(list.size()>0){
+//            throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+//        }
+//
+//        //鍏堟煡鎵炬湰浜虹殑鏁版嵁
+//        LambdaQueryWrapper<ZInfoUser> zInfoLqw = new LambdaQueryWrapper<>();
+//        zInfoLqw.eq(ZInfoUser::getUserId,userId);
+//        ZInfoUser master = zInfoUserService.getOne(zInfoLqw);
+//
+//        ZfMaster zfMaster = new ZfMaster();
+//        zfMaster.setPetId(zfPet.getId());
+//        zfMaster.setName(master.getNickName());
+//        zfMaster.setCertificateType("韬唤璇�");
+//        zfMaster.setCertificateNo(master.getIdNo());
+//        zfMaster.setPhoneNo(master.getPhoneNumber());
+//        zfMaster.setAddress(master.getAlwaysAddress());
+//
+//        zfMasterService.save(zfMaster);
+//
+//        zfPetService.save(zfPet);
+//
+//        return AjaxResult.success();
+//
+//    }
 
     private LambdaQueryWrapper<ZfPet> uniqueCondition(ZfPet zfPet) {
         LambdaQueryWrapper<ZfPet> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(zfPet.getFamilyId()!=null,ZfPet::getFamilyId,zfPet.getFamilyId());
         lqw.eq(StringUtils.isNotEmpty(zfPet.getIdNum()),ZfPet::getIdNum,zfPet.getIdNum());
         lqw.eq(StringUtils.isNotEmpty(zfPet.getSecurityCode()),ZfPet::getSecurityCode,zfPet.getSecurityCode());
         lqw.eq(StringUtils.isNotEmpty(zfPet.getType()),ZfPet::getType,zfPet.getType());
@@ -135,8 +296,10 @@
         return lqw;
     }
 
-    private LambdaQueryWrapper<ZfPet> buildCondition(ZfPet zfPet) {
+    private LambdaQueryWrapper<ZfPet> buildCondition(ZfPet zfPet,List<Long> familyIdList) {
         LambdaQueryWrapper<ZfPet> lqw = new LambdaQueryWrapper<>();
+        lqw.orderByDesc(ZfPet::getCreateTime);
+        lqw.in(ZfPet::getFamilyId,familyIdList);
         lqw.like(StringUtils.isNotEmpty(zfPet.getIdNum()),ZfPet::getIdNum,zfPet.getIdNum());
         lqw.like(StringUtils.isNotEmpty(zfPet.getSecurityCode()),ZfPet::getSecurityCode,zfPet.getSecurityCode());
         lqw.like(StringUtils.isNotEmpty(zfPet.getType()),ZfPet::getType,zfPet.getType());

--
Gitblit v1.9.1