| | |
| | | import com.ruoyi.domain.dto.GenealogyExportDto; |
| | | import com.ruoyi.domain.dto.RelationDto; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import com.ruoyi.service.ZfRoleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | @Resource |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | private ZfFamilyService zfFamilyService; |
| | | |
| | | @Resource |
| | | private ZfRoleService zfRoleService; |
| | | |
| | | // @GetMapping("/all") |
| | | // public AjaxResult listAll(ZInfoUser zInfoUser){ |
| | |
| | | public AjaxResult getInfo() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | return AjaxResult.success(zInfoUserService.getById(userId)); |
| | | return AjaxResult.success(zInfoUserService.getInfoById(userId)); |
| | | } |
| | | // |
| | | |
| | |
| | | util.exportExcel(response,list,"家谱记录数据"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZRotation; |
| | | import com.ruoyi.service.ZRotationService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 0:20 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/rotation") |
| | | public class ZRotationController { |
| | | |
| | | @Resource |
| | | private ZRotationService zRotationService; |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult getRotation(){ |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | List<ZRotation> rotationList = zRotationService.getByUserId(userId); |
| | | return AjaxResult.success(rotationList); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | public AjaxResult addRotation(ZRotation zRotation){ |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | zRotation.setUid(userId); |
| | | zRotationService.save(zRotation); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete/{ids}") |
| | | public AjaxResult deleteRotation(@PathVariable Long[] ids){ |
| | | zRotationService.removeByIds(Arrays.asList(ids)); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出保洁收纳记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfClean zfClean) |
| | | // { |
| | | // List<ZfClean> list = zfCleanService.selectByCondition(zfClean); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | // util.exportExcel(response, list, "保洁收纳记录数据"); |
| | | // } |
| | | /** |
| | | * 导出保洁收纳记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "保洁收纳记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfClean zfClean) |
| | | { |
| | | List<ZfClean> list = zfCleanService.selectByCondition(zfClean); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.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<ZfClean> list = zfCleanService.selectByIds(ids); |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfClean zfClean) |
| | | { |
| | | return zfCleanService.addData2(zfClean); |
| | | return zfCleanService.addData(zfClean); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfClean zfClean) |
| | | { |
| | | return toAjax(zfCleanService.updateById(zfClean)); |
| | | return zfCleanService.updateData(zfClean); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfCleanService.removeByIds(Arrays.asList(ids))); |
| | | return zfCleanService.deleteData(ids); |
| | | } |
| | | |
| | | } |
| | |
| | | util.exportExcel(response,list,"收藏荣誉导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出收藏和荣誉记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "收藏和荣誉记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfCollection zfCollection) |
| | | // { |
| | | // List<ZfCollection> list = zfCollectionService.selectByCondition(zfCollection); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfCollection> util = new ExcelUtil<>(ZfCollection.class); |
| | | // util.exportExcel(response, list, "收藏和荣誉记录数据"); |
| | | // } |
| | | /** |
| | | * 导出收藏和荣誉记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfCollection zfCollection) |
| | | { |
| | | List<ZfCollection> list = zfCollectionService.selectByCondition(zfCollection); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfCollection> util = new ExcelUtil<>(ZfCollection.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<ZfCollection> list = zfCollectionService.selectByIds(ids); |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfCollection zfCollection) |
| | | { |
| | | return zfCollectionService.addData2(zfCollection); |
| | | return zfCollectionService.addData(zfCollection); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfCollection zfCollection) |
| | | { |
| | | return toAjax(zfCollectionService.updateById(zfCollection)); |
| | | return zfCollectionService.updateData(zfCollection); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfCollectionService.removeByIds(Arrays.asList(ids))); |
| | | return zfCollectionService.deleteData(ids); |
| | | } |
| | | |
| | | |
| | |
| | | util.exportExcel(response,list,"通讯录导入模板"); |
| | | } |
| | | |
| | | /** |
| | | * 导出通讯录记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "通讯录记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfContact zfContact) |
| | | { |
| | | List<ZfContact> list = zfContactService.selectByCondition(zfContact); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | util.exportExcel(response, list, "通讯录记录数据"); |
| | | } |
| | | // /** |
| | | // * 导出通讯录记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "通讯录记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfContact zfContact) |
| | | // { |
| | | // List<ZfContact> list = zfContactService.selectByCondition(zfContact); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.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<ZfContact> list = zfContactService.selectByIds(ids); |
| | |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception |
| | | { |
| | | ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | List<ZfContact> eventList = util.importExcel(file.getInputStream()); |
| | | log.info("通讯录列表为:{}",eventList); |
| | | if (zfContactService.saveBatch(eventList)) { |
| | | return AjaxResult.success("导入数据成功"); |
| | | } |
| | | return AjaxResult.error("导入数据失败"); |
| | | // ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | // List<ZfContact> eventList = util.importExcel(file.getInputStream()); |
| | | // log.info("通讯录列表为:{}",eventList); |
| | | // if (zfContactService.saveBatch(eventList)) { |
| | | // return AjaxResult.success("导入数据成功"); |
| | | // } |
| | | // return AjaxResult.error("导入数据失败"); |
| | | return zfContactService.importExcel(file); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfContact zfContact) |
| | | { |
| | | return (zfContactService.addData2(zfContact)); |
| | | return (zfContactService.addData(zfContact)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfContact zfContact) |
| | | { |
| | | return toAjax(zfContactService.updateById(zfContact)); |
| | | return zfContactService.updateData(zfContact); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfContactService.removeByIds(Arrays.asList(ids))); |
| | | return zfContactService.deleteData(ids); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭小医生记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfDoctor zfDoctor) |
| | | // { |
| | | // List<ZfDoctor> list = zfDoctorService.selectByCondition(zfDoctor); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | // util.exportExcel(response, list, "家庭小医生记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭小医生记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfDoctor zfDoctor) |
| | | { |
| | | List<ZfDoctor> list = zfDoctorService.selectByCondition(zfDoctor); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | util.exportExcel(response, list, "家庭小医生记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭小医生记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭小医生记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export1(HttpServletResponse response, @PathVariable Long[] ids) |
| | | @PostMapping("/export/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfDoctor> list = zfDoctorService.selectByIds(ids); |
| | | log.info("导出记录为:{}",list); |
| | |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception |
| | | { |
| | | ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | List<ZfDoctor> eventList = util.importExcel(file.getInputStream()); |
| | | log.info("家庭小医生列表为:{}",eventList); |
| | | // ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | // List<ZfDoctor> eventList = util.importExcel(file.getInputStream()); |
| | | // log.info("家庭小医生列表为:{}",eventList); |
| | | // |
| | | // if (zfDoctorService.saveBatch(eventList)) { |
| | | // return AjaxResult.success("导入数据成功"); |
| | | // } |
| | | // return AjaxResult.error("导入数据失败"); |
| | | |
| | | if (zfDoctorService.saveBatch(eventList)) { |
| | | return AjaxResult.success("导入数据成功"); |
| | | } |
| | | return AjaxResult.error("导入数据失败"); |
| | | return zfDoctorService.importExcel(file); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfDoctor zfDoctor) |
| | | { |
| | | return zfDoctorService.mySave(zfDoctor); |
| | | return zfDoctorService.addData(zfDoctor); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfDoctor zfDoctor) |
| | | { |
| | | return toAjax(zfDoctorService.updateById(zfDoctor)); |
| | | return zfDoctorService.updateData(zfDoctor); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfDoctorService.removeByIds(Arrays.asList(ids))); |
| | | return zfDoctorService.deleteData(ids); |
| | | } |
| | | |
| | | } |
| | |
| | | util.exportExcel(response,list,"家庭收支台账导入模板"); |
| | | } |
| | | |
| | | // /** |
| | | // * 导出家庭收支台账记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfEconomy zfEconomy) |
| | | // { |
| | | // List<ZfEconomy> list = zfEconomyService.selectByCondition(zfEconomy); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | // util.exportExcel(response, list, "家庭收支台账记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭收支台账记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfEconomy zfEconomy) |
| | | { |
| | | List<ZfEconomy> list = zfEconomyService.selectByCondition(zfEconomy); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.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<ZfEconomy> list = zfEconomyService.selectByIds(ids); |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return zfEconomyService.addData2(zfEconomy); |
| | | return zfEconomyService.addData(zfEconomy); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return toAjax(zfEconomyService.updateById(zfEconomy)); |
| | | return zfEconomyService.updateData(zfEconomy); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfEconomyService.removeByIds(Arrays.asList(ids))); |
| | | return zfEconomyService.deleteData(ids); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭设备记录列表 |
| | | // */ |
| | | //// @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, "家庭设备记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭设备记录列表 |
| | | */ |
| | | // @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.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export1(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | @PostMapping("/export/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfEquipment> list = zfEquipmentService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
| | | ExcelUtil<ZfEquipment> util = new ExcelUtil<ZfEquipment>(ZfEquipment.class); |
| | | util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | util.exportExcel(response, list, "家庭设备数据"); |
| | | |
| | | } |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEquipment zfEquipment) |
| | | { |
| | | return zfEquipmentService.addData2(zfEquipment); |
| | | return zfEquipmentService.addData(zfEquipment); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfEquipment zfEquipment) |
| | | { |
| | | return toAjax(zfEquipmentService.updateById(zfEquipment)); |
| | | return zfEquipmentService.updateData(zfEquipment); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfEquipmentService.removeByIds(Arrays.asList(ids))); |
| | | return zfEquipmentService.deleteData(ids); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 导出家庭大事件记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, ZfEvent zfEvent) { |
| | | // List<ZfEvent> list = new ArrayList<>(); |
| | | // |
| | | // list = zfEventService.selectByCondition(zfEvent); |
| | | // log.info("导出记录为:{}", list); |
| | | // ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | // util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | // |
| | | // } |
| | | /** |
| | | * 导出家庭大事件记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ZfEvent zfEvent) { |
| | | List<ZfEvent> list = new ArrayList<>(); |
| | | |
| | | list = zfEventService.selectByCondition(zfEvent); |
| | | log.info("导出记录为:{}", list); |
| | | ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | |
| | | } |
| | | /** |
| | | * 导出家庭大事件记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export1(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | @PostMapping("/export/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfEvent> list = zfEventService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
| | | ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception { |
| | | |
| | | return zfEventService.importExcel(file); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEvent zfEvent) { |
| | | return zfEventService.addData2(zfEvent); |
| | | return zfEventService.addData(zfEvent); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfEvent zfEvent) { |
| | | return toAjax(zfEventService.updateById(zfEvent)); |
| | | return zfEventService.updateData(zfEvent); |
| | | } |
| | | // |
| | | |
| | |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) { |
| | | return toAjax(zfEventService.removeByIds(Arrays.asList(ids))); |
| | | return zfEventService.deleteData(ids); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:43 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | |
| | | @RestController |
| | | @RequestMapping("/family") |
| | | public class ZfFamilyController { |
| | | @Resource |
| | | ZfFamilyService zfFamilyService; |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult getAllFamily(){ |
| | | return AjaxResult.success(zfFamilyService.list()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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); |
| | | return zfPropertyService.selectDataList(zfProperty, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | |
| | | util.exportExcel(response,list,"家庭资产导入模板"); |
| | | } |
| | | |
| | | /** |
| | | * 导出家庭资产记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭资产记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response,ZfProperty zfProperty) |
| | | { |
| | | List<ZfProperty> list = zfPropertyService.selectByCondition(zfProperty); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | util.exportExcel(response, list, "家庭资产记录数据"); |
| | | } |
| | | // /** |
| | | // * 导出家庭资产记录列表 |
| | | // */ |
| | | //// @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | // @Log(title = "家庭资产记录", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response,ZfProperty zfProperty) |
| | | // { |
| | | // List<ZfProperty> list = zfPropertyService.selectByCondition(zfProperty); |
| | | // log.info("导出记录为:{}",list); |
| | | // ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | // util.exportExcel(response, list, "家庭资产记录数据"); |
| | | // } |
| | | /** |
| | | * 导出家庭资产记录列表 |
| | | */ |
| | | @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | @PostMapping("/export/{ids}") |
| | | public void export1(HttpServletResponse response, @PathVariable Long[] ids) { |
| | | List<ZfProperty> list = zfPropertyService.selectByIds(ids); |
| | | log.info("导出记录为:{}", list); |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<ZfProperty>(ZfProperty.class); |
| | | util.exportExcel(response, list, "家庭大事件记录数据"); |
| | | |
| | | util.exportExcel(response, list, "家庭资产记录数据"); |
| | | } |
| | | // |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfProperty zfProperty) |
| | | { |
| | | return zfPropertyService.addData2(zfProperty); |
| | | return zfPropertyService.addData(zfProperty); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfProperty zfProperty) |
| | | { |
| | | return toAjax(zfPropertyService.updateById(zfProperty)); |
| | | return zfPropertyService.updateData(zfProperty); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfPropertyService.removeByIds(Arrays.asList(ids))); |
| | | return zfPropertyService.deleteData(ids); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.service.ZfRoleService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:44 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/role") |
| | | public class ZfRoleController { |
| | | |
| | | @Resource |
| | | private ZfRoleService zfRoleService; |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult getAllRole(){ |
| | | return AjaxResult.success(zfRoleService.list()); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.constant; |
| | | |
| | | import org.omg.CORBA.PUBLIC_MEMBER; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | |
| | | **/ |
| | | public class MenuAuthority { |
| | | |
| | | public static final String PROPERTY_LIST="2007"; |
| | | public static final String COLLECTION_LIST="2018"; |
| | | public static final String ECONOMY_LIST="2023"; |
| | | public static final String EVENT_LIST="2013"; |
| | | public static final String EQUIPMENT_LIST="2017"; |
| | | public static final String CONTACT_LIST="2021"; |
| | | public static final String CLEAN_LIST="2020"; |
| | | public static final String PROPERTY_LIST="2000"; |
| | | public static final String PROPERTY_LIST_ADD="2001"; |
| | | public static final String PROPERTY_LIST_UPDATE="2002"; |
| | | public static final String PROPERTY_LIST_REMOVE="2003"; |
| | | public static final String COLLECTION_LIST="2004"; |
| | | public static final String COLLECTION_LIST_ADD="2005"; |
| | | public static final String COLLECTION_LIST_UPDATE="2006"; |
| | | public static final String COLLECTION_LIST_REMOVE="2007"; |
| | | public static final String ECONOMY_LIST="2008"; |
| | | public static final String ECONOMY_LIST_ADD="2009"; |
| | | public static final String ECONOMY_LIST_UPDATE="2010"; |
| | | public static final String ECONOMY_LIST_REMOVE="2011"; |
| | | public static final String EVENT_LIST="2012"; |
| | | public static final String EVENT_LIST_ADD="2013"; |
| | | public static final String EVENT_LIST_UPDATE="2014"; |
| | | public static final String EVENT_LIST_REMOVE="2015"; |
| | | public static final String EQUIPMENT_LIST="2016"; |
| | | public static final String EQUIPMENT_LIST_ADD="2017"; |
| | | public static final String EQUIPMENT_LIST_UPDATE="2018"; |
| | | public static final String EQUIPMENT_LIST_REMOVE="2019"; |
| | | public static final String CONTACT_LIST="2020"; |
| | | public static final String CONTACT_LIST_ADD="2021"; |
| | | public static final String CONTACT_LIST_UPDATE="2022"; |
| | | public static final String CONTACT_LIST_REMOVE="2023"; |
| | | public static final String CLEAN_LIST="2024"; |
| | | public static final String CLEAN_LIST_ADD="2025"; |
| | | public static final String CLEAN_LIST_UPDATE="2026"; |
| | | public static final String CLEAN_LIST_REMOVE="2027"; |
| | | |
| | | public static final String FAMILY_ROOT="2028"; |
| | | |
| | | public static final String DOCTOR_LIST="2029"; |
| | | public static final String DOCTOR_LIST_ADD="2030"; |
| | | 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_ADD="2034"; |
| | | public static final String FAMILY_PET_UPDATE="2035"; |
| | | public static final String FAMILY_PET_REMOVE="2036"; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 11:05 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | public class ZAuthority implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long uid; |
| | | |
| | | /** |
| | | * 家庭id |
| | | */ |
| | | private Long fid; |
| | | |
| | | /** |
| | | * 权限码 |
| | | */ |
| | | private Long authority; |
| | | |
| | | } |
| | |
| | | @Excel(name = "是否是本家庭成员",readConverterExp = "0=否,1=是") |
| | | private Integer isMyFamily; |
| | | |
| | | @TableField(exist = false) |
| | | private String familyName; |
| | | |
| | | @TableField(exist = false) |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 图片地址 |
| | | */ |
| | |
| | | /** |
| | | * 家庭id |
| | | */ |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 其他家庭授权id |
New file |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 0:17 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | public class ZRotation implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | private Long uid; |
| | | |
| | | private String url; |
| | | |
| | | private Integer flag; |
| | | } |
| | |
| | | private String url; |
| | | |
| | | @Excel(name="所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | |
| | | /** |
| | |
| | | * 所属家庭id |
| | | */ |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | |
| | | private String url; |
| | | |
| | | @Excel(name="所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | /** |
| | | * 创建时间 |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createTime; |
| | | |
| | | private Long familyId; |
| | | |
| | | @TableField(exist = false) |
| | | private Integer ownData; |
| | | |
| | | } |
| | |
| | | private String url; |
| | | |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | |
| | | * 家庭id |
| | | */ |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | private String url; |
| | | |
| | |
| | | private String url; |
| | | |
| | | @Excel(name="所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | |
| | | /** |
New file |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 11:27 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | @ToString |
| | | @TableName("zf_family") |
| | | public class ZfFamily implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 家庭名称 |
| | | */ |
| | | private String name; |
| | | } |
| | |
| | | * 家庭id |
| | | */ |
| | | @Excel(name = "所属家庭编号(导入数据时请删除此栏)") |
| | | private String familyId; |
| | | private Long familyId; |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
New file |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:29 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Data |
| | | @ToString |
| | | public class ZfRole implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | private String name; |
| | | } |
New file |
| | |
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 13:22 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Mapper |
| | | public interface ZAuthorityMapper extends BaseMapper<ZAuthority> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.domain.ZRotation; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 0:18 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Mapper |
| | | public interface ZRotationMapper extends BaseMapper<ZRotation> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:28 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Mapper |
| | | public interface ZfFamilyMapper extends BaseMapper<ZfFamily> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.fasterxml.jackson.databind.ser.Serializers; |
| | | import com.ruoyi.domain.ZfRole; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:29 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Mapper |
| | | public interface ZfRoleMapper extends BaseMapper<ZfRole> { |
| | | } |
| | |
| | | |
| | | List<ZfProperty> selectByCondition(ZfProperty zfProperty); |
| | | |
| | | AjaxResult selectPropertyList(ZfProperty zfProperty,Integer pageNum,Integer pageSize); |
| | | List<ZfProperty> selectByIds( Long[] ids); |
| | | AjaxResult selectDataList(ZfProperty zfProperty,Integer pageNum,Integer pageSize); |
| | | List<ZfProperty> selectByIds(Long[] ids); |
| | | |
| | | List<ZfProperty> selectByFamilyIds(Long[] familyIds); |
| | | AjaxResult addData(ZfProperty zfProperty); |
| | | |
| | | AjaxResult addData2(ZfProperty zfProperty); |
| | | AjaxResult updateData(ZfProperty zfProperty); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | |
| | | // AjaxResult addData2(ZfProperty zfProperty); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | } |
New file |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 13:21 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | public interface ZAuthorityService extends IService<ZAuthority> { |
| | | List<ZAuthority> getAuthority(); |
| | | } |
| | |
| | | List<Genealogy> selectByIds(Long[] ids); |
| | | |
| | | List<Genealogy> selectDatas(List<GenealogyExportDto> params); |
| | | |
| | | ZInfoUser getInfoById(Long userId); |
| | | |
| | | ZInfoUser getMyself(); |
| | | } |
New file |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.domain.ZRotation; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 0:18 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | public interface ZRotationService extends IService<ZRotation> { |
| | | List<ZRotation> getByUserId(Long userId); |
| | | } |
| | |
| | | List<ZfClean> selectByCondition(ZfClean zfClean); |
| | | |
| | | List<ZfClean> selectByIds(Long[] ids); |
| | | AjaxResult addData(ZfClean zfClean); |
| | | // AjaxResult addData(ZfClean zfClean); |
| | | |
| | | AjaxResult addData2(ZfClean zfClean); |
| | | // AjaxResult addData2(ZfClean zfClean); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult updateData(ZfClean zfClean); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | |
| | | AjaxResult addData(ZfClean zfClean); |
| | | } |
| | |
| | | List<ZfCollection> selectByIds(Long[] ids); |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult addData2(ZfCollection zfCollection); |
| | | // AjaxResult addData2(ZfCollection zfCollection); |
| | | |
| | | AjaxResult addData(ZfCollection zfCollection); |
| | | |
| | | AjaxResult updateData(ZfCollection zfCollection); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | } |
| | |
| | | List<ZfContact> selectByIds(Long [] ids); |
| | | AjaxResult addData(ZfContact zfContact); |
| | | |
| | | AjaxResult addData2(ZfContact zfContact); |
| | | // AjaxResult addData2(ZfContact zfContact); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult updateData(ZfContact zfContact); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZfDoctor; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | List<ZfDoctor> selectByCondition(ZfDoctor zfDoctor); |
| | | List<ZfDoctor> selectByIds(Long[] ids); |
| | | |
| | | AjaxResult mySave(ZfDoctor zfDoctor); |
| | | // AjaxResult mySave(ZfDoctor zfDoctor); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult addData(ZfDoctor zfDoctor); |
| | | |
| | | AjaxResult updateData(ZfDoctor zfDoctor); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | |
| | | } |
| | |
| | | List<ZfEconomy> selectByIds(Long [] ids); |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult addData2(ZfEconomy zfEconomy); |
| | | // AjaxResult addData2(ZfEconomy zfEconomy); |
| | | |
| | | AjaxResult addData(ZfEconomy zfEconomy); |
| | | |
| | | AjaxResult updateData(ZfEconomy zfEconomy); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | } |
| | |
| | | List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment); |
| | | List<ZfEquipment> selectByIds(Long[] ids); |
| | | AjaxResult addData(ZfEquipment zfEquipment); |
| | | AjaxResult addData2(ZfEquipment zfEquipment); |
| | | // AjaxResult addData2(ZfEquipment zfEquipment); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | |
| | | AjaxResult updateData(ZfEquipment zfEquipment); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | } |
| | |
| | | |
| | | AjaxResult addData(ZfEvent zfEvent); |
| | | |
| | | AjaxResult addData2(ZfEvent zfEvent); |
| | | // AjaxResult addData2(ZfEvent zfEvent); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult updateData(ZfEvent zfEvent); |
| | | |
| | | AjaxResult deleteData(Long[] ids); |
| | | } |
New file |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:31 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public interface ZfFamilyService extends IService<ZfFamily> { |
| | | } |
New file |
| | |
| | | package com.ruoyi.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.domain.ZfRole; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:31 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public interface ZfRoleService extends IService<ZfRole> { |
| | | } |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.constant.MenuAuthority; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.mapper.ZfPropertyMapper; |
| | | import com.ruoyi.service.IZfPropertyService; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.PROPERTY_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) { |
| | | |
| | | // private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) { |
| | | // LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | // |
| | | // lqw.like(!StringUtils.isEmpty(zfProperty.getType()), ZfProperty::getType, zfProperty.getType()) |
| | | // .like(!StringUtils.isEmpty(zfProperty.getTitle()), ZfProperty::getTitle, zfProperty.getTitle()) |
| | | // .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) |
| | | // .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) |
| | | // .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) |
| | | // .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) |
| | | // .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()) |
| | | // .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); |
| | | // return lqw; |
| | | // } |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty,List<Long> familyIdList){ |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | |
| | | lqw.like(!StringUtils.isEmpty(zfProperty.getType()), ZfProperty::getType, zfProperty.getType()) |
| | |
| | | .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) |
| | | .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) |
| | | .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) |
| | | .eq(zfProperty.getFamilyId()!=null,ZfProperty::getFamilyId,zfProperty.getFamilyId()) |
| | | .in(ZfProperty::getFamilyId,familyIdList) |
| | | .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()) |
| | | .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfProperty::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfProperty::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfProperty::getCreateTime); |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // } else { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfProperty::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfProperty::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfProperty::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfProperty::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(PROPERTY_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(PROPERTY_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(PROPERTY_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(PROPERTY_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private Long listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfProperty> selectByCondition(ZfProperty zfProperty) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lambdaQueryWrapper = buildCondition(zfProperty, familyIds, secondFamilyIds); |
| | | List<ZfProperty> beanRecords = list(lambdaQueryWrapper); |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(PROPERTY_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty, idList); |
| | | List<ZfProperty> beanRecords = list(lqw); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | private static List<ZfProperty> markOwnData(String familyIds, List<ZfProperty> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | // private static List<ZfProperty> markOwnData(String familyIds, List<ZfProperty> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult selectPropertyList(ZfProperty zfProperty, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty, familyIds, secondFamilyAuthority); |
| | | public AjaxResult selectDataList(ZfProperty zfProperty, Integer pageNum, Integer pageSize) { |
| | | |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(PROPERTY_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty, idList); |
| | | |
| | | Page<ZfProperty> zfPropertyPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfProperty> pageResult = page(zfPropertyPage, lqw); |
| | | |
| | | List<ZfProperty> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfProperty> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfProperty> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | public List<ZfProperty> markOwnData(Long familyId,List<ZfProperty> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfProperty zfProperty) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfProperty.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfProperty.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfProperty)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfProperty.getFamilyId() + "数据的权限"); |
| | | } |
| | | public List<ZfProperty> selectByFamilyIds(Long[] familyIds) { |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ZfProperty::getFamilyId,familyIds); |
| | | return list(lqw); |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData(ZfProperty zfProperty) { |
| | | // |
| | | // String familyIds = listFamilyIds(); |
| | | // boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // for (String familyId : familyList) { |
| | | // if (familyId.equals(zfProperty.getFamilyId())) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (zfProperty.getFamilyId().equals(familyIds)) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // if (flag) { |
| | | // if (save(zfProperty)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // throw new RuntimeException("你没有操作该家庭号为" + zfProperty.getFamilyId() + "数据的权限"); |
| | | // } |
| | | // } |
| | | |
| | | // public Boolean checkAuthority(ZfProperty zfProperty, String code){ |
| | | // ZInfoUser myself = zInfoUserService.getMyself(); |
| | | // Long familyId = myself.getFamilyId(); |
| | | // |
| | | // List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | // List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(code)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | // familyIdList.add(familyId); |
| | | // |
| | | // if(zfProperty.getFamilyId() == null){ |
| | | // return false; |
| | | // } |
| | | // |
| | | // if (!familyIdList.contains(zfProperty.getFamilyId())) { |
| | | // throw new RuntimeException("你没有权限操作家庭"+zfProperty.getFamilyId()+"的数据"); |
| | | // } |
| | | // return true; |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfProperty zfProperty) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | public AjaxResult addData(ZfProperty zfProperty){ |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfProperty.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfProperty.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfProperty.setFamilyId(myFamilyId); |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(PROPERTY_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfProperty.getFamilyId()!=null && !familyIdList.contains(zfProperty.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfProperty.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfProperty.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfProperty> lqw = uniqueCondition(zfProperty); |
| | | List<ZfProperty> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfProperty zfProperty) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfProperty.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(PROPERTY_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfProperty)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfProperty> dataList = zfPropertyService.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(PROPERTY_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfProperty data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfPropertyService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfProperty zfProperty) { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfProperty.getFamilyId())) { |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if (StringUtils.isEmpty(myFamilyId)) { |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")) { |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfProperty.setFamilyId(myFamilyIds[0]); |
| | | // } else { |
| | | // zfProperty.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfProperty> lqw = uniqueCondition(zfProperty); |
| | | // List<ZfProperty> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfProperty)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> uniqueCondition(ZfProperty zfProperty) { |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(!StringUtils.isEmpty(zfProperty.getType()), ZfProperty::getType, zfProperty.getType()) |
| | | .eq(zfProperty.getFamilyId()!=null,ZfProperty::getFamilyId,zfProperty.getFamilyId()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getTitle()), ZfProperty::getTitle, zfProperty.getTitle()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) |
| | |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfProperty zfProperty : propertyList) { |
| | | zfPropertyService.addData2(zfProperty); |
| | | zfPropertyService.addData(zfProperty); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
New file |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import com.ruoyi.mapper.ZAuthorityMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 13:23 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public class ZAuthorityServiceImpl extends ServiceImpl<ZAuthorityMapper, ZAuthority> implements ZAuthorityService { |
| | | /** |
| | | * 查询当前用户的权限 |
| | | */ |
| | | @Override |
| | | public List<ZAuthority> getAuthority() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZAuthority::getUid,userId); |
| | | |
| | | return list(lqw); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.domain.dto.*; |
| | | import com.ruoyi.mapper.ZInfoUserMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import com.ruoyi.service.ZfRelationService; |
| | | import com.ruoyi.service.ZfRoleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | private ZfFamilyService zfFamilyService; |
| | | |
| | | @Resource |
| | | private ZfRoleService zfRoleService; |
| | | |
| | | @Override |
| | | public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) { |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 给用户授权的方法 |
| | | * @param empowerDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult empower(EmpowerDto empowerDto) { |
| | | |
| | | //得到dto中的信息 |
| | | String otherUserId = empowerDto.getUserId(); |
| | | String destinationFamilyId = empowerDto.getFamilyId(); |
| | | List<String> authorityList = empowerDto.getAuthorityList(); |
| | | |
| | | String familyId = getMyFamilyId(); |
| | | checkAuthorization(familyId, destinationFamilyId,true); |
| | | |
| | | //授权 //3{2007 1988 1004} |
| | | String finalStr = getFinalStr(destinationFamilyId, authorityList); |
| | | |
| | | //更新被授权用户的权限 |
| | | LambdaQueryWrapper<ZInfoUser> lqw2 = new LambdaQueryWrapper<>(); |
| | | lqw2.eq(ZInfoUser::getUserId,otherUserId); |
| | | ZInfoUser otherUser = getOne(lqw2); |
| | | String secondFamilyId = otherUser.getSecondFamilyId(); |
| | | |
| | | String replaceFamilyId=null; |
| | | |
| | | boolean save=true; |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyId)){ |
| | | //如果原来就已经有被赋予权限了,那么需要判断是不是跟这个家庭号有关的权限 |
| | | |
| | | //这个secondFamilyId是当前用户的完整权限字段 |
| | | if(secondFamilyId.contains(",")){ |
| | | String[] split = secondFamilyId.split(","); |
| | | for (int i = 0; i < split.length; i++) { |
| | | String fid = split[i].substring(0, split[i].indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | save=false; |
| | | split[i]=finalStr; |
| | | break; |
| | | } |
| | | } |
| | | List<String> finalList = Arrays.asList(split); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (String s : finalList) { |
| | | stringBuilder.append(s).append(","); |
| | | } |
| | | stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | |
| | | replaceFamilyId = stringBuilder.toString(); |
| | | |
| | | }else { |
| | | String fid = secondFamilyId.substring(0, secondFamilyId.indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | save=false; |
| | | replaceFamilyId=finalStr; |
| | | } |
| | | } |
| | | |
| | | if(save){ |
| | | //需要追加,没有匹配到对应的家庭号 |
| | | replaceFamilyId=secondFamilyId+","+finalStr; |
| | | }else { |
| | | //不需要追加 |
| | | } |
| | | |
| | | }else { |
| | | //原来就没有权限了 |
| | | replaceFamilyId=finalStr; |
| | | } |
| | | |
| | | LambdaUpdateWrapper<ZInfoUser> uw = new LambdaUpdateWrapper<>(); |
| | | uw.eq(ZInfoUser::getUserId,otherUserId).set(ZInfoUser::getSecondFamilyId,replaceFamilyId); |
| | | if (update(null,uw)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | // /** |
| | | // * 给用户授权的方法 |
| | | // * @param empowerDto |
| | | // * @return |
| | | // */ |
| | | // @Override |
| | | // @Transactional |
| | | // public AjaxResult empower(EmpowerDto empowerDto) { |
| | | // |
| | | // //得到dto中的信息 |
| | | // String otherUserId = empowerDto.getUserId(); |
| | | // String destinationFamilyId = empowerDto.getFamilyId(); |
| | | // List<String> authorityList = empowerDto.getAuthorityList(); |
| | | // |
| | | // String familyId = getMyFamilyId(); |
| | | // checkAuthorization(familyId, destinationFamilyId,true); |
| | | // |
| | | // //授权 //3{2007 1988 1004} |
| | | // String finalStr = getFinalStr(destinationFamilyId, authorityList); |
| | | // |
| | | // //更新被授权用户的权限 |
| | | // LambdaQueryWrapper<ZInfoUser> lqw2 = new LambdaQueryWrapper<>(); |
| | | // lqw2.eq(ZInfoUser::getUserId,otherUserId); |
| | | // ZInfoUser otherUser = getOne(lqw2); |
| | | // String secondFamilyId = otherUser.getSecondFamilyId(); |
| | | // |
| | | // String replaceFamilyId=null; |
| | | // |
| | | // boolean save=true; |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyId)){ |
| | | // //如果原来就已经有被赋予权限了,那么需要判断是不是跟这个家庭号有关的权限 |
| | | // |
| | | // //这个secondFamilyId是当前用户的完整权限字段 |
| | | // if(secondFamilyId.contains(",")){ |
| | | // String[] split = secondFamilyId.split(","); |
| | | // for (int i = 0; i < split.length; i++) { |
| | | // String fid = split[i].substring(0, split[i].indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | // if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | // //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | // save=false; |
| | | // split[i]=finalStr; |
| | | // break; |
| | | // } |
| | | // } |
| | | // List<String> finalList = Arrays.asList(split); |
| | | // StringBuilder stringBuilder = new StringBuilder(); |
| | | // for (String s : finalList) { |
| | | // stringBuilder.append(s).append(","); |
| | | // } |
| | | // stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | // |
| | | // replaceFamilyId = stringBuilder.toString(); |
| | | // |
| | | // }else { |
| | | // String fid = secondFamilyId.substring(0, secondFamilyId.indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | // if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | // //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | // save=false; |
| | | // replaceFamilyId=finalStr; |
| | | // } |
| | | // } |
| | | // |
| | | // if(save){ |
| | | // //需要追加,没有匹配到对应的家庭号 |
| | | // replaceFamilyId=secondFamilyId+","+finalStr; |
| | | // }else { |
| | | // //不需要追加 |
| | | // } |
| | | // |
| | | // }else { |
| | | // //原来就没有权限了 |
| | | // replaceFamilyId=finalStr; |
| | | // } |
| | | // |
| | | // LambdaUpdateWrapper<ZInfoUser> uw = new LambdaUpdateWrapper<>(); |
| | | // uw.eq(ZInfoUser::getUserId,otherUserId).set(ZInfoUser::getSecondFamilyId,replaceFamilyId); |
| | | // if (update(null,uw)) { |
| | | // return AjaxResult.success(); |
| | | // }else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | |
| | | private void checkAuthorization(String familyId, String destinationFamilyId,boolean flag) { |
| | |
| | | } |
| | | } |
| | | |
| | | private String getMyFamilyId() { |
| | | private Long getMyFamilyId() { |
| | | //得到自己的家庭id信息 |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long myUserId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getUserId,myUserId); |
| | | ZInfoUser zInfoUser = getOne(lqw); |
| | | String familyId = zInfoUser.getFamilyId(); |
| | | Long familyId = zInfoUser.getFamilyId(); |
| | | return familyId; |
| | | } |
| | | |
| | |
| | | |
| | | List<ZInfoUser> allPeopleList = list(); |
| | | List<ZInfoUser> result = null; |
| | | try { |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | // try { |
| | | // result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | // .map(people -> { |
| | | // if(depth>1){ |
| | | // people.setIdentity(1); |
| | | // //根据配偶id查询配偶的数据,封装好一起返回 |
| | | // Long spouseId = people.getSpouseId(); |
| | | // ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | // spouse.setIdentity(1); |
| | | // people.setSpouse(spouse); |
| | | // people.setChildList(fillChildren(people, allPeopleList, depth-1)); |
| | | // } |
| | | // return people; |
| | | // }).collect(Collectors.toList()); |
| | | // } catch (NullPointerException e) { |
| | | // throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | // } |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)&&people.getIsMyFamily()==1) |
| | | .map(people -> { |
| | | if(depth>1){ |
| | | people.setIdentity(1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = people.getSpouseId(); |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | spouse.setIdentity(1); |
| | | people.setSpouse(spouse); |
| | | people.setChildList(fillChildren(people, allPeopleList, depth-1)); |
| | | } |
| | | return people; |
| | | }).collect(Collectors.toList()); |
| | | } catch (NullPointerException e) { |
| | | throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | } |
| | | |
| | | |
| | | return AjaxResult.success(result); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ZInfoUser getInfoById(Long userId) { |
| | | ZInfoUser user = getById(userId); |
| | | Long familyId = user.getFamilyId(); |
| | | String familyName = zfFamilyService.getById(familyId).getName(); |
| | | String roleName = zfRoleService.getById(user.getRoleId()).getName(); |
| | | user.setFamilyName(familyName); |
| | | user.setRoleName(roleName); |
| | | return user; |
| | | } |
| | | |
| | | // @Override |
| | | // public ZInfoUser getInfoById(Long userId) { |
| | | // |
| | | // ZInfoUser user = getById(userId); |
| | | // |
| | | // //用逗号隔开的家庭id |
| | | // String familyId = user.getFamilyId(); |
| | | // |
| | | // //在自己家庭中角色的id |
| | | // Long roleId = user.getRoleId(); |
| | | // |
| | | // ArrayList<String> familyList = new ArrayList<>(); |
| | | // |
| | | // //填充所属家庭 |
| | | // if(familyId.contains(",")){ |
| | | // String[] familyIds = familyId.split(","); |
| | | // for (String id : familyIds) { |
| | | // familyList.add(zfFamilyService.getById(id).getName()); |
| | | // } |
| | | // }else { |
| | | // familyList.add(zfFamilyService.getById(familyId).getName()); |
| | | // } |
| | | // |
| | | // user.setFamilyList(familyList); |
| | | // |
| | | // //填充所在家庭的角色 |
| | | // user.setRole(zfRoleService.getById(roleId).getName()); |
| | | // |
| | | // return user; |
| | | // } |
| | | |
| | | @Override |
| | | public ZInfoUser getMyself() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | return getById(userId); |
| | | } |
| | | |
| | | |
| | | private void recursionFindUser(List<ZInfoUser> treeList){ |
| | | if (treeList==null||treeList.isEmpty()){ |
| | |
| | | return one; |
| | | else { |
| | | one.setIdentity(people.getIdentity()+1); |
| | | |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = one.getSpouseId(); |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | one.setSpouse(spouse); |
| | | if(spouseId!=null){ |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | spouse.setIdentity(people.getIdentity()+1); |
| | | one.setSpouse(spouse); |
| | | } |
| | | List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | System.out.println(one); |
New file |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.domain.ZRotation; |
| | | import com.ruoyi.mapper.ZRotationMapper; |
| | | import com.ruoyi.service.ZRotationService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-15 0:19 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public class ZRotationServiceImpl extends ServiceImpl<ZRotationMapper, ZRotation> implements ZRotationService { |
| | | @Override |
| | | public List<ZRotation> getByUserId(Long userId) { |
| | | LambdaQueryWrapper<ZRotation> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZRotation::getUid,userId); |
| | | return list(lqw); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ruoyi.domain.ZfClean; |
| | | import com.ruoyi.mapper.ZfCleanMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCleanService; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.CLEAN_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZfCleanService zfCleanService; |
| | | |
| | | private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean) { |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfClean> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfClean::getCreateTime); |
| | | lqw.eq(zfClean.getKind() != null, ZfClean::getKind, zfClean.getKind()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getSuitable()), ZfClean::getSuitable, zfClean.getSuitable()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getType()), ZfClean::getType, zfClean.getType()) |
| | |
| | | .like(StringUtils.isNotEmpty(zfClean.getLocation()), ZfClean::getLocation, zfClean.getLocation()) |
| | | .like(StringUtils.isNotEmpty(zfClean.getRemark()), ZfClean::getRemark, zfClean.getRemark()) |
| | | .eq(zfClean.getHappenTime() != null, ZfClean::getHappenTime, zfClean.getHappenTime()) |
| | | .in(ZfClean::getFamilyId,familyIdList) |
| | | .between(zfClean.getHappenStartTime() != null && zfClean.getHappenEndTime() != null, ZfClean::getHappenTime, zfClean.getHappenStartTime(), zfClean.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | |
| | | .eq(StringUtils.isNotEmpty(zfClean.getPlace()), ZfClean::getPlace, zfClean.getPlace()) |
| | | .eq(StringUtils.isNotEmpty(zfClean.getLocation()), ZfClean::getLocation, zfClean.getLocation()) |
| | | .eq(StringUtils.isNotEmpty(zfClean.getRemark()), ZfClean::getRemark, zfClean.getRemark()) |
| | | .eq(zfClean.getFamilyId()!=null,ZfClean::getFamilyId,zfClean.getFamilyId()) |
| | | .eq(zfClean.getHappenTime() != null, ZfClean::getHappenTime, zfClean.getHappenTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfClean::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfClean::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfClean::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(CLEAN_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(CLEAN_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private LambdaQueryWrapper<ZfClean> buildCondition(ZfClean zfClean, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // } else { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfClean::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfClean::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfClean::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfClean::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(CLEAN_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(CLEAN_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private String listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfClean> selectByCondition(ZfClean zfClean) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfClean> lambdaQueryWrapper = buildCondition(zfClean, familyIds, secondFamilyIds); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfClean> lambdaQueryWrapper = buildCondition(zfClean, familyIds, secondFamilyIds); |
| | | // List<ZfClean> beanRecords = list(lambdaQueryWrapper); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyIds, beanRecords); |
| | | |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CLEAN_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfClean> lambdaQueryWrapper = buildCondition(zfClean, idList); |
| | | List<ZfClean> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return list; |
| | | } |
| | | |
| | | private static List<ZfClean> markOwnData(String familyIds, List<ZfClean> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | // private static List<ZfClean> markOwnData(String familyIds, List<ZfClean> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | public List<ZfClean> markOwnData(Long familyId,List<ZfClean> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfClean zfClean, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean, familyIds, secondFamilyAuthority); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean, familyIds, secondFamilyAuthority); |
| | | // |
| | | // Page<ZfClean> zfCleanPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfClean> pageResult = page(zfCleanPage, lqw); |
| | | // |
| | | // List<ZfClean> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // |
| | | // List<ZfClean> dtoResult = markOwnData(familyIds, beanRecords); |
| | | // |
| | | // HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | // 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(CLEAN_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfClean> lqw = buildCondition(zfClean, idList); |
| | | |
| | | |
| | | Page<ZfClean> zfCleanPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfClean> pageResult = page(zfCleanPage, lqw); |
| | | |
| | | List<ZfClean> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfClean> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfClean> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | |
| | | @Override |
| | | public AjaxResult addData(ZfClean zfClean) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfClean.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfClean.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfClean)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | // String familyIds = listFamilyIds(); |
| | | // boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // for (String familyId : familyList) { |
| | | // if (familyId.equals(zfClean.getFamilyId())) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (zfClean.getFamilyId().equals(familyIds)) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // if (flag) { |
| | | // if (save(zfClean)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // throw new RuntimeException("你没有操作该家庭号为" + zfClean.getFamilyId() + "数据的权限"); |
| | | // } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfClean.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfClean zfClean) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfClean.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfClean.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfClean.setFamilyId(myFamilyId); |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CLEAN_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfClean.getFamilyId()!=null && !familyIdList.contains(zfClean.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfClean.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfClean.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfClean> lqw = uniqueCondition(zfClean); |
| | | List<ZfClean> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfClean zfClean) { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfClean.getFamilyId())) { |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if (StringUtils.isEmpty(myFamilyId)) { |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")) { |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfClean.setFamilyId(myFamilyIds[0]); |
| | | // } else { |
| | | // zfClean.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfClean> lqw = uniqueCondition(zfClean); |
| | | // List<ZfClean> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfClean)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfClean> util = new ExcelUtil<>(ZfClean.class); |
| | | List<ZfClean> propertyList = null; |
| | | List<ZfClean> dataList = null; |
| | | try { |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", propertyList); |
| | | log.info("数据列表为:{}", dataList); |
| | | |
| | | for (ZfClean zfClean : propertyList) { |
| | | zfCleanService.addData2(zfClean); |
| | | for (ZfClean zfClean : dataList) { |
| | | zfCleanService.addData(zfClean); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfClean zfClean) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfClean.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CLEAN_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfClean)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfClean> dataList = zfCleanService.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(CLEAN_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfClean data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfCleanService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import com.ruoyi.mapper.ZfCollectionMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCollectionService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.COLLECTION_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection) { |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfCollection::getCreateTime); |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getType()),ZfCollection::getType,zfCollection.getType()); |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getName()),ZfCollection::getName,zfCollection.getName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getSource()),ZfCollection::getSource,zfCollection.getSource()); |
| | |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getPrice()),ZfCollection::getPrice,zfCollection.getPrice()); |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getLocation()),ZfCollection::getLocation,zfCollection.getLocation()); |
| | | lqw.like(StringUtils.isNotEmpty(zfCollection.getRemark()),ZfCollection::getRemark,zfCollection.getRemark()); |
| | | lqw.in(ZfCollection::getFamilyId,familyIdList); |
| | | lqw.eq(zfCollection.getHappenTime() != null, ZfCollection::getHappenTime, zfCollection.getHappenTime()); |
| | | lqw.between(zfCollection.getHappenStartTime() != null && zfCollection.getHappenEndTime() != null, ZfCollection::getHappenTime, zfCollection.getHappenStartTime(), zfCollection.getHappenEndTime()); |
| | | return lqw; |
| | |
| | | lqw.eq(StringUtils.isNotEmpty(zfCollection.getLocation()),ZfCollection::getLocation,zfCollection.getLocation()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfCollection.getRemark()),ZfCollection::getRemark,zfCollection.getRemark()); |
| | | lqw.eq(zfCollection.getHappenTime() != null, ZfCollection::getHappenTime, zfCollection.getHappenTime()); |
| | | lqw.eq(zfCollection.getFamilyId()!=null,ZfCollection::getFamilyId,zfCollection.getFamilyId()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfCollection> lqw = buildCondition(zfCollection); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | }else{ |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfCollection::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfCollection::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfCollection::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(COLLECTION_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(COLLECTION_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfCollection> lqw = buildCondition(zfCollection); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // }else{ |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfCollection::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfCollection::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfCollection::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfCollection::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(COLLECTION_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(COLLECTION_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private String listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfCollection> selectByCondition(ZfCollection zfCollection) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfCollection> lambdaQueryWrapper = buildCondition(zfCollection, familyIds, secondFamilyIds); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfCollection> lambdaQueryWrapper = buildCondition(zfCollection, familyIds, secondFamilyIds); |
| | | // List<ZfCollection> beanRecords = list(lambdaQueryWrapper); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyIds, beanRecords); |
| | | |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(COLLECTION_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfCollection> lambdaQueryWrapper = buildCondition(zfCollection, idList); |
| | | List<ZfCollection> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return list; |
| | | } |
| | | |
| | | private List<ZfCollection> markOwnData(String familyIds, List<ZfCollection> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | // private List<ZfCollection> markOwnData(String familyIds, List<ZfCollection> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | public List<ZfCollection> markOwnData(Long familyId,List<ZfCollection> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfCollection zfCollection, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfCollection> lqw = buildCondition(zfCollection, familyIds, secondFamilyAuthority); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfCollection> lqw = buildCondition(zfCollection, familyIds, secondFamilyAuthority); |
| | | // |
| | | // Page<ZfCollection> zfCollectionPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfCollection> pageResult = page(zfCollectionPage, lqw); |
| | | // |
| | | // List<ZfCollection> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // |
| | | // List<ZfCollection> dtoResult = markOwnData(familyIds, beanRecords); |
| | | // |
| | | // HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | // 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(COLLECTION_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfCollection> lqw = buildCondition(zfCollection, idList); |
| | | |
| | | |
| | | Page<ZfCollection> zfCollectionPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfCollection> pageResult = page(zfCollectionPage, lqw); |
| | | |
| | | List<ZfCollection> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfCollection> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfCollection> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfCollection zfCollection){ |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfCollection.getFamilyId())){ |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if(StringUtils.isEmpty(myFamilyId)){ |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")){ |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfCollection.setFamilyId(myFamilyIds[0]); |
| | | // }else { |
| | | // zfCollection.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfCollection> lqw = uniqueCondition(zfCollection); |
| | | // List<ZfCollection> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfCollection)) { |
| | | // return AjaxResult.success(); |
| | | // }else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfCollection zfCollection){ |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | public AjaxResult addData(ZfCollection zfCollection) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfCollection.getFamilyId())){ |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(myFamilyId)){ |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")){ |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfCollection.setFamilyId(myFamilyIds[0]); |
| | | }else { |
| | | zfCollection.setFamilyId(myFamilyId); |
| | | 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()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfCollection.getFamilyId()!=null && !familyIdList.contains(zfCollection.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfCollection.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfCollection.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfCollection> lqw = uniqueCondition(zfCollection); |
| | | List<ZfCollection> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if (save(zfCollection)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfCollection zfCollection) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfCollection.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(COLLECTION_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfCollection)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfCollection> dataList = zfCollectionService.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(COLLECTION_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfCollection data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfCollectionService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | |
| | | log.info("准备要导入的数据列表为:{}", dataList); |
| | | |
| | | for (ZfCollection zfCollection : dataList) { |
| | | zfCollectionService.addData2(zfCollection); |
| | | zfCollectionService.addData(zfCollection); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | |
| | | import com.ruoyi.domain.ZfContact; |
| | | import com.ruoyi.domain.ZfContact; |
| | | import com.ruoyi.mapper.ZfContactMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfContactService; |
| | | import com.ruoyi.service.ZfContactService; |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.CONTACT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | ZfContactService zfContactService; |
| | | |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact) { |
| | | private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfContact> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfContact::getCreateTime); |
| | | lqw.in(ZfContact::getFamilyId,familyIdList); |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getMyName()),ZfContact::getMyName,zfContact.getMyName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getNickName()),ZfContact::getNickName,zfContact.getNickName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfContact.getName()),ZfContact::getName,zfContact.getName()); |
| | |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfContact::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfContact::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfContact::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(CONTACT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(CONTACT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private LambdaQueryWrapper<ZfContact> buildCondition(ZfContact zfContact, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // } else { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfContact::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfContact::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfContact::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfContact::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(CONTACT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(CONTACT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private String listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfContact> selectByCondition(ZfContact zfContact) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact, familyIds, secondFamilyIds); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact, familyIds, secondFamilyIds); |
| | | // List<ZfContact> beanRecords = list(lambdaQueryWrapper); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyIds, beanRecords); |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CONTACT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfContact> lambdaQueryWrapper = buildCondition(zfContact, idList); |
| | | List<ZfContact> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return list; |
| | | } |
| | | |
| | | private static List<ZfContact> markOwnData(String familyIds, List<ZfContact> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | // private static List<ZfContact> markOwnData(String familyIds, List<ZfContact> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | public List<ZfContact> markOwnData(Long familyId,List<ZfContact> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfContact zfContact, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact, familyIds, secondFamilyAuthority); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact, familyIds, secondFamilyAuthority); |
| | | // |
| | | // Page<ZfContact> zfContactPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfContact> pageResult = page(zfContactPage, lqw); |
| | | // |
| | | // List<ZfContact> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // |
| | | // List<ZfContact> dtoResult = markOwnData(familyIds, beanRecords); |
| | | // |
| | | // HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | // 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(CONTACT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfContact> lqw = buildCondition(zfContact, idList); |
| | | |
| | | |
| | | Page<ZfContact> zfContactPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfContact> pageResult = page(zfContactPage, lqw); |
| | | |
| | | List<ZfContact> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfContact> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfContact> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | |
| | | @Override |
| | | public AjaxResult addData(ZfContact zfContact) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfContact.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfContact.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfContact)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | // String familyIds = listFamilyIds(); |
| | | // boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // for (String familyId : familyList) { |
| | | // if (familyId.equals(zfContact.getFamilyId())) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (zfContact.getFamilyId().equals(familyIds)) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // if (flag) { |
| | | // if (save(zfContact)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // throw new RuntimeException("你没有操作该家庭号为" + zfContact.getFamilyId() + "数据的权限"); |
| | | // } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfContact.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfContact zfContact) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfContact.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfContact.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfContact.setFamilyId(myFamilyId); |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CONTACT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfContact.getFamilyId()!=null && !familyIdList.contains(zfContact.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfContact.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfContact.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfContact> lqw = uniqueCondition(zfContact); |
| | | List<ZfContact> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfContact zfContact) { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfContact.getFamilyId())) { |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if (StringUtils.isEmpty(myFamilyId)) { |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")) { |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfContact.setFamilyId(myFamilyIds[0]); |
| | | // } else { |
| | | // zfContact.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfContact> lqw = uniqueCondition(zfContact); |
| | | // List<ZfContact> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfContact)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | private LambdaQueryWrapper<ZfContact> uniqueCondition(ZfContact zfContact) { |
| | | LambdaQueryWrapper<ZfContact> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | lqw.eq(StringUtils.isNotEmpty(zfContact.getTwitter()),ZfContact::getTwitter,zfContact.getTwitter()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfContact.getRemark()),ZfContact::getRemark,zfContact.getRemark()); |
| | | lqw.eq(zfContact.getHappenTime() != null, ZfContact::getHappenTime, zfContact.getHappenTime()); |
| | | lqw.eq(zfContact.getFamilyId()!=null,ZfContact::getFamilyId,zfContact.getFamilyId()); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfContact> util = new ExcelUtil<>(ZfContact.class); |
| | | List<ZfContact> propertyList = null; |
| | | List<ZfContact> dataList = null; |
| | | try { |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", propertyList); |
| | | log.info("数据列表为:{}", dataList); |
| | | |
| | | for (ZfContact zfContact : propertyList) { |
| | | zfContactService.addData2(zfContact); |
| | | for (ZfContact zfContact : dataList) { |
| | | zfContactService.addData(zfContact); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfContact zfContact) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfContact.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(CONTACT_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfContact)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfContact> dataList = zfContactService.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(CONTACT_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfContact data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfContactService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ZfDoctor; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfPet; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.mapper.ZfDoctorMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfDoctorService; |
| | | import com.ruoyi.service.ZfDoctorService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | 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> |
| | |
| | | @Slf4j |
| | | public class ZfDoctorServiceImpl extends ServiceImpl<ZfDoctorMapper, ZfDoctor> implements ZfDoctorService { |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | ZfDoctorService zfDoctorService; |
| | | |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | @Override |
| | | public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor); |
| | | lqw.orderByDesc(ZfDoctor::getCreateTime); |
| | | // LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor); |
| | | // lqw.orderByDesc(ZfDoctor::getCreateTime); |
| | | // |
| | | // Page<ZfDoctor> ZfDoctorPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfDoctor> pageResult = page(ZfDoctorPage, 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(DOCTOR_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList); |
| | | |
| | | Page<ZfDoctor> ZfDoctorPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfDoctor> pageResult = page(ZfDoctorPage, lqw); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | | Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw); |
| | | |
| | | List<ZfDoctor> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfDoctor> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfDoctor> selectByCondition(ZfDoctor zfDoctor) { |
| | | LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor); |
| | | lambdaQueryWrapper.orderByDesc(ZfDoctor::getCreateTime); |
| | | List<ZfDoctor> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}", list); |
| | | return list; |
| | | // LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor); |
| | | // lambdaQueryWrapper.orderByDesc(ZfDoctor::getCreateTime); |
| | | // List<ZfDoctor> 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(DOCTOR_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor, idList); |
| | | List<ZfDoctor> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | public List<ZfDoctor> markOwnData(Long familyId,List<ZfDoctor> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult mySave(ZfDoctor zfDoctor) { |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfDoctor> util = new ExcelUtil<>(ZfDoctor.class); |
| | | List<ZfDoctor> dataList = null; |
| | | try { |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("数据列表为:{}", dataList); |
| | | |
| | | for (ZfDoctor zfDoctor : dataList) { |
| | | zfDoctorService.addData(zfDoctor); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfDoctor zfDoctor) { |
| | | 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(DOCTOR_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfDoctor.getFamilyId()!=null && !familyIdList.contains(zfDoctor.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfDoctor.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfDoctor.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfDoctor> lqw = uniqueCondition(zfDoctor); |
| | | List<ZfDoctor> list = list(lqw); |
| | | if (list.size() > 0) { |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfDoctor zfDoctor) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfDoctor.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfDoctor)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfDoctor> dataList = zfDoctorService.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(DOCTOR_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfDoctor data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfDoctorService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult mySave(ZfDoctor zfDoctor) { |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfDoctor> lqw = uniqueCondition(zfDoctor); |
| | | // List<ZfDoctor> list = list(lqw); |
| | | // if (list.size() > 0) { |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfDoctor)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // |
| | | // } |
| | | |
| | | private LambdaQueryWrapper<ZfDoctor> uniqueCondition(ZfDoctor zfDoctor) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getEffect()), ZfDoctor::getEffect, zfDoctor.getEffect()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getSuitable()), ZfDoctor::getSuitable, zfDoctor.getSuitable()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getRemark()), ZfDoctor::getRemark, zfDoctor.getRemark()); |
| | | lqw.eq(zfDoctor.getFamilyId()!=null,ZfDoctor::getFamilyId,zfDoctor.getFamilyId()); |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor) { |
| | | private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ZfDoctor::getFamilyId,familyIdList); |
| | | lqw.orderByDesc(ZfDoctor::getCreateTime); |
| | | lqw.like(StringUtils.isNotEmpty(zfDoctor.getType()), ZfDoctor::getType, zfDoctor.getType()) |
| | | .like(StringUtils.isNotEmpty(zfDoctor.getSymptom()), ZfDoctor::getSymptom, zfDoctor.getSymptom()) |
| | | .like(StringUtils.isNotEmpty(zfDoctor.getDuration()), ZfDoctor::getDuration, zfDoctor.getDuration()) |
| | |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.mapper.ZfEconomyMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEconomyService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.COLLECTION_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.ECONOMY_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | private LambdaQueryWrapper<ZfEconomy> buildCondition(ZfEconomy zfEconomy) { |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfEconomy> buildCondition(ZfEconomy zfEconomy,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfEconomy> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfEconomy::getCreateTime); |
| | | lqw.in(ZfEconomy::getFamilyId,familyIdList); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getType()),ZfEconomy::getType,zfEconomy.getType()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getKind()),ZfEconomy::getKind,zfEconomy.getKind()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getPrice()),ZfEconomy::getPrice,zfEconomy.getPrice()); |
| | |
| | | lqw.eq(StringUtils.isNotEmpty(zfEconomy.getUsePeople()),ZfEconomy::getUsePeople,zfEconomy.getUsePeople()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEconomy.getBalance()),ZfEconomy::getBalance,zfEconomy.getBalance()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEconomy.getRemark()),ZfEconomy::getRemark,zfEconomy.getRemark()); |
| | | lqw.eq(zfEconomy.getFamilyId()!=null,ZfEconomy::getFamilyId,zfEconomy.getFamilyId()); |
| | | lqw.eq(zfEconomy.getHappenTime() != null, ZfEconomy::getHappenTime, zfEconomy.getHappenTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEconomy> buildCondition(ZfEconomy zfEconomy, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfEconomy> lqw = buildCondition(zfEconomy); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | }else{ |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEconomy::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEconomy::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEconomy::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(ECONOMY_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(ECONOMY_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private LambdaQueryWrapper<ZfEconomy> buildCondition(ZfEconomy zfEconomy, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfEconomy> lqw = buildCondition(zfEconomy); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // }else{ |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfEconomy::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfEconomy::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfEconomy::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfEconomy::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(ECONOMY_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(ECONOMY_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private String listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfEconomy> selectByCondition(ZfEconomy zfEconomy) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEconomy> lambdaQueryWrapper = buildCondition(zfEconomy, familyIds, secondFamilyIds); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfEconomy> lambdaQueryWrapper = buildCondition(zfEconomy, familyIds, secondFamilyIds); |
| | | // List<ZfEconomy> beanRecords = list(lambdaQueryWrapper); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyIds, beanRecords); |
| | | |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(ECONOMY_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfEconomy> lambdaQueryWrapper = buildCondition(zfEconomy, idList); |
| | | List<ZfEconomy> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return list; |
| | | } |
| | | |
| | | private List<ZfEconomy> markOwnData(String familyIds, List<ZfEconomy> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | // private List<ZfEconomy> markOwnData(String familyIds, List<ZfEconomy> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfEconomy zfEconomy, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEconomy> lqw = buildCondition(zfEconomy, familyIds, secondFamilyAuthority); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfEconomy> lqw = buildCondition(zfEconomy, familyIds, secondFamilyAuthority); |
| | | // |
| | | // Page<ZfEconomy> zfEconomyPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfEconomy> pageResult = page(zfEconomyPage, lqw); |
| | | // |
| | | // List<ZfEconomy> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // |
| | | // List<ZfEconomy> dtoResult = markOwnData(familyIds, beanRecords); |
| | | // |
| | | // HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | // 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(ECONOMY_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEconomy> lqw = buildCondition(zfEconomy, idList); |
| | | |
| | | |
| | | Page<ZfEconomy> zfEconomyPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEconomy> pageResult = page(zfEconomyPage, lqw); |
| | | |
| | | List<ZfEconomy> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfEconomy> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfEconomy> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfEconomy zfEconomy){ |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfEconomy.getFamilyId())){ |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(myFamilyId)){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")){ |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfEconomy.setFamilyId(myFamilyIds[0]); |
| | | }else { |
| | | zfEconomy.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfEconomy> lqw = uniqueCondition(zfEconomy); |
| | | List<ZfEconomy> list = list(lqw); |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if (save(zfEconomy)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | public List<ZfEconomy> markOwnData(Long familyId,List<ZfEconomy> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfEconomy zfEconomy){ |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfEconomy.getFamilyId())){ |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if(StringUtils.isEmpty(myFamilyId)){ |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")){ |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfEconomy.setFamilyId(myFamilyIds[0]); |
| | | // }else { |
| | | // zfEconomy.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfEconomy> lqw = uniqueCondition(zfEconomy); |
| | | // List<ZfEconomy> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfEconomy)) { |
| | | // return AjaxResult.success(); |
| | | // }else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | @Override |
| | |
| | | log.info("准备要导入的数据列表为:{}", dataList); |
| | | |
| | | for (ZfEconomy zfEconomy : dataList) { |
| | | zfEconomyService.addData2(zfEconomy); |
| | | zfEconomyService.addData(zfEconomy); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfEconomy zfEconomy) { |
| | | 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(ECONOMY_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfEconomy.getFamilyId()!=null && !familyIdList.contains(zfEconomy.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfEconomy.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfEconomy.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfEconomy> lqw = uniqueCondition(zfEconomy); |
| | | List<ZfEconomy> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if (save(zfEconomy)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfEconomy zfEconomy) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfEconomy.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(ECONOMY_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfEconomy)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfEconomy> dataList = zfEconomyService.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(ECONOMY_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfEconomy data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfEconomyService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.mapper.ZfEquipmentMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEquipmentService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.EQUIPMENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZfEquipmentService zfEquipmentService; |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment) { |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfEquipment> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfEquipment::getCreateTime); |
| | | 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.eq(zfEquipment.getHappenTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenTime()); |
| | | lqw.in(ZfEquipment::getFamilyId,familyIdList); |
| | | lqw.between(zfEquipment.getHappenStartTime() != null && zfEquipment.getHappenEndTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenStartTime(), zfEquipment.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | //------------------------------------------------------------------------------------------ |
| | | private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEquipment::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEquipment::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEquipment::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(EQUIPMENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(EQUIPMENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // //------------------------------------------------------------------------------------------ |
| | | // private LambdaQueryWrapper<ZfEquipment> buildCondition(ZfEquipment zfEquipment, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // } else { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfEquipment::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfEquipment::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfEquipment::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfEquipment::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(EQUIPMENT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(EQUIPMENT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private String listFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfEquipment> selectByCondition(ZfEquipment zfEquipment) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, familyIds, secondFamilyIds); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, familyIds, secondFamilyIds); |
| | | // List<ZfEquipment> beanRecords = list(lambdaQueryWrapper); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyIds, beanRecords); |
| | | |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EQUIPMENT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfEquipment> lambdaQueryWrapper = buildCondition(zfEquipment, idList); |
| | | List<ZfEquipment> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | list = list(); |
| | | return list; } |
| | | |
| | | private static List<ZfEquipment> markOwnData(String familyIds, List<ZfEquipment> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | // private static List<ZfEquipment> markOwnData(String familyIds, List<ZfEquipment> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | public List<ZfEquipment> markOwnData(Long familyId,List<ZfEquipment> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfEquipment zfEquipment, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, familyIds, secondFamilyAuthority); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | // LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, familyIds, secondFamilyAuthority); |
| | | // |
| | | // Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNum, pageSize); |
| | | // Page<ZfEquipment> pageResult = page(zfEquipmentPage, lqw); |
| | | // |
| | | // List<ZfEquipment> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // |
| | | // List<ZfEquipment> dtoResult = markOwnData(familyIds, beanRecords); |
| | | // |
| | | // HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | // 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(EQUIPMENT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment, idList); |
| | | |
| | | |
| | | Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEquipment> pageResult = page(zfEquipmentPage, lqw); |
| | | |
| | | List<ZfEquipment> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfEquipment> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfEquipment> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfEquipment zfEquipment) { |
| | | public AjaxResult addData(ZfEquipment zfEquipment){ |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | 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) { |
| | | if (save(zfEquipment)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfEquipment.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfEquipment zfEquipment) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfEquipment.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfEquipment.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfEquipment.setFamilyId(myFamilyId); |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EQUIPMENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfEquipment.getFamilyId()!=null && !familyIdList.contains(zfEquipment.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfEquipment.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfEquipment.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfEquipment> lqw = uniqueCondition(zfEquipment); |
| | | List<ZfEquipment> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData(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) { |
| | | // if (save(zfEquipment)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // throw new RuntimeException("你没有操作该家庭号为" + zfEquipment.getFamilyId() + "数据的权限"); |
| | | // } |
| | | // } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfEquipment zfEquipment) { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfEquipment.getFamilyId())) { |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if (StringUtils.isEmpty(myFamilyId)) { |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")) { |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfEquipment.setFamilyId(myFamilyIds[0]); |
| | | // } else { |
| | | // zfEquipment.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfEquipment> lqw = uniqueCondition(zfEquipment); |
| | | // List<ZfEquipment> list = list(lqw); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfEquipment)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfEquipment zfEquipment : propertyList) { |
| | | zfEquipmentService.addData2(zfEquipment); |
| | | zfEquipmentService.addData(zfEquipment); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfEquipment zfEquipment) { |
| | | |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfEquipment.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EQUIPMENT_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfEquipment)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfEquipment> dataList = zfEquipmentService.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(EQUIPMENT_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfEquipment data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfEquipmentService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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.ZfEvent; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.mapper.ZfEventMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEventService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.EVENT_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.PROPERTY_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | ZfEventService zfEventService; |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent) { |
| | | @Resource |
| | | ZAuthorityService zAuthorityService; |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent,List<Long> familyIdList) { |
| | | LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfEvent::getCreateTime); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getAddress()), ZfEvent::getAddress, zfEvent.getAddress()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getPeople()), ZfEvent::getPeople, zfEvent.getPeople()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getTitle()), ZfEvent::getTitle, zfEvent.getTitle()); |
| | | lqw.like(!StringUtils.isEmpty(zfEvent.getRemark()), ZfEvent::getRemark, zfEvent.getRemark()); |
| | | lqw.eq(zfEvent.getHappenTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenTime()); |
| | | lqw.in(ZfEvent::getFamilyId,familyIdList); |
| | | lqw.between(zfEvent.getHappenStartTime() != null && zfEvent.getHappenEndTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenStartTime(), zfEvent.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | |
| | | lqw.eq(!StringUtils.isEmpty(zfEvent.getPeople()), ZfEvent::getPeople, zfEvent.getPeople()); |
| | | lqw.eq(!StringUtils.isEmpty(zfEvent.getTitle()), ZfEvent::getTitle, zfEvent.getTitle()); |
| | | lqw.eq(!StringUtils.isEmpty(zfEvent.getRemark()), ZfEvent::getRemark, zfEvent.getRemark()); |
| | | lqw.eq(zfEvent.getFamilyId()!=null,ZfEvent::getFamilyId,zfEvent.getFamilyId()); |
| | | lqw.eq(zfEvent.getHappenTime() != null, ZfEvent::getHappenTime, zfEvent.getHappenTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent, String familyIds, String secondFamilyAuthority) { |
| | | //模糊查询的条件 |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent); |
| | | |
| | | //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | boolean flag = false; |
| | | |
| | | StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | |
| | | //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | |
| | | if (secondFamilyAuthority.contains(",")) { |
| | | //逗号隔开得到如下串:3{2007 2018 2015} |
| | | String[] authorityList = secondFamilyAuthority.split(","); |
| | | for (String authorityAndId : authorityList) { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | } |
| | | |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | } |
| | | } |
| | | //将StringBuffer转成String |
| | | String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | |
| | | //第一家庭号的条件 |
| | | if (familyIds.contains(",")) { |
| | | flag = true; |
| | | } |
| | | |
| | | //第二家庭号的条件 |
| | | if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | if (secondFamilyIds.contains(",")) { |
| | | String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | if (flag) { |
| | | //如果第一家庭号和第二家庭号都有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } |
| | | |
| | | } else { |
| | | if (flag) { |
| | | //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | String[] familyList = familyIds.split(","); |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } else { |
| | | //如果第一家庭号和第二家庭号都没有逗号 |
| | | String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | } |
| | | } |
| | | } else { |
| | | //如果没有第二家庭号 |
| | | if (flag) { |
| | | String[] familyList = familyIds.split(","); |
| | | lqw.in(ZfEvent::getFamilyId, familyList); |
| | | } else { |
| | | lqw.eq(ZfEvent::getFamilyId, familyIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfEvent::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | //得到权限串 |
| | | String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | |
| | | if (authorities.contains(" ")) { |
| | | //空格隔开得到菜单id,看是否有对应的权限 |
| | | String[] authorityIdList = authorities.split(" "); |
| | | for (String s : authorityIdList) { |
| | | if (s.equals(EVENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (authorities.equals(EVENT_LIST)) { |
| | | secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ZInfoUser getMySelf() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | } |
| | | |
| | | private String listFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getFamilyId(); |
| | | } |
| | | |
| | | private String listSecondFamilyIds() { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | return mySelf.getSecondFamilyId(); |
| | | } |
| | | // private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent, String familyIds, String secondFamilyAuthority) { |
| | | // //模糊查询的条件 |
| | | // LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent); |
| | | // |
| | | // //定义一个布尔标记,标记第一家庭号是否有逗号 |
| | | // boolean flag = false; |
| | | // |
| | | // StringBuilder secondFamilyIdsBuffer = new StringBuilder(); |
| | | // |
| | | // //处理传入的secondFamilyAuthority 3{2007 2018 2015},4{2007 2019} |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyAuthority)) { |
| | | // |
| | | // if (secondFamilyAuthority.contains(",")) { |
| | | // //逗号隔开得到如下串:3{2007 2018 2015} |
| | | // String[] authorityList = secondFamilyAuthority.split(","); |
| | | // for (String authorityAndId : authorityList) { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, authorityAndId); |
| | | // } |
| | | // |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // |
| | | // } else { |
| | | // setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | // //把后面的逗号去掉 |
| | | // if (secondFamilyIdsBuffer.length() > 1) { |
| | | // secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // //将StringBuffer转成String |
| | | // String secondFamilyIds = secondFamilyIdsBuffer.toString(); |
| | | // |
| | | // //第一家庭号的条件 |
| | | // if (familyIds.contains(",")) { |
| | | // flag = true; |
| | | // } |
| | | // |
| | | // //第二家庭号的条件 |
| | | // if (StringUtils.isNotEmpty(secondFamilyIds)) { |
| | | // if (secondFamilyIds.contains(",")) { |
| | | // String[] secondFamilyIdList = secondFamilyIds.split(","); |
| | | // if (flag) { |
| | | // //如果第一家庭号和第二家庭号都有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIdList); |
| | | // lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号没有逗号但是第二家庭号有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(secondFamilyIdList, familyIds); |
| | | // lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // |
| | | // } else { |
| | | // if (flag) { |
| | | // //如果第一家庭号有逗号但第二家庭号没有逗号 |
| | | // String[] familyList = familyIds.split(","); |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyList, secondFamilyIds); |
| | | // lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | // } else { |
| | | // //如果第一家庭号和第二家庭号都没有逗号 |
| | | // String[] totalFamilyIdList = ArraysUtil.appendToArray(familyIds, secondFamilyIds); |
| | | // lqw.in(ZfEvent::getFamilyId, totalFamilyIdList); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // //如果没有第二家庭号 |
| | | // if (flag) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // lqw.in(ZfEvent::getFamilyId, familyList); |
| | | // } else { |
| | | // lqw.eq(ZfEvent::getFamilyId, familyIds); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // lqw.orderByDesc(ZfEvent::getCreateTime); |
| | | // return lqw; |
| | | // } |
| | | // |
| | | // private void setSecondFamilyAuthority(StringBuilder secondFamilyIdsBuffer, String authorityAndId) { |
| | | // //得到权限串 |
| | | // String authorities = authorityAndId.substring(2, authorityAndId.length() - 1); |
| | | // |
| | | // if (authorities.contains(" ")) { |
| | | // //空格隔开得到菜单id,看是否有对应的权限 |
| | | // String[] authorityIdList = authorities.split(" "); |
| | | // for (String s : authorityIdList) { |
| | | // if (s.equals(EVENT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (authorities.equals(EVENT_LIST)) { |
| | | // secondFamilyIdsBuffer.append(authorityAndId.charAt(0)).append(","); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private ZInfoUser getMySelf() { |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | // return zInfoUserService.getOne(zInfoUserLambdaQueryWrapper); |
| | | // } |
| | | // |
| | | // private Long listFamilyId() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getFamilyId(); |
| | | // } |
| | | // |
| | | // private String listSecondFamilyIds() { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // return mySelf.getSecondFamilyId(); |
| | | // } |
| | | |
| | | @Override |
| | | public List<ZfEvent> selectByCondition(ZfEvent zfEvent) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lambdaQueryWrapper = buildCondition(zfEvent, familyIds, secondFamilyIds); |
| | | // Long familyId = listFamilyId(); |
| | | // String secondFamilyIds = listSecondFamilyIds(); |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | |
| | | LambdaQueryWrapper<ZfEvent> lambdaQueryWrapper = buildCondition(zfEvent, idList); |
| | | List<ZfEvent> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | return markOwnData(familyId, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return list; |
| | | } |
| | | |
| | | private static List<ZfEvent> markOwnData(String familyIds, List<ZfEvent> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | public List<ZfEvent> markOwnData(Long familyId,List<ZfEvent> beanRecords){ |
| | | return beanRecords.stream().peek( |
| | | bean -> { |
| | | if (bean.getFamilyId() == familyId) { |
| | | bean.setOwnData(1); |
| | | } else { |
| | | bean.setOwnData(0); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | record.setOwnData(1); |
| | | } |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | // private static List<ZfEvent> markOwnData(String familyIds, List<ZfEvent> beanRecords) { |
| | | // return beanRecords.stream().peek(record -> { |
| | | // String recordFamilyId = record.getFamilyId(); |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyIdList = familyIds.split(","); |
| | | // for (String familyId : familyIdList) { |
| | | // if (familyId.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (familyIds.equals(recordFamilyId)) { |
| | | // record.setOwnData(1); |
| | | // } |
| | | // } |
| | | // }).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfEvent zfEvent, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent, familyIds, secondFamilyAuthority); |
| | | //要查自己家庭的 |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | //也要查别人授权的 |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | //加上自己家庭的id |
| | | idList.add(familyId); |
| | | // String familyIds = listFamilyIds(); |
| | | // String secondFamilyAuthority = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent, idList); |
| | | |
| | | |
| | | Page<ZfEvent> zfEventPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfEvent> pageResult = page(zfEventPage, lqw); |
| | | |
| | | List<ZfEvent> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfEvent> dtoResult = markOwnData(familyIds, beanRecords); |
| | | List<ZfEvent> dtoResult = markOwnData(familyId, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData(ZfEvent zfEvent) { |
| | | // |
| | | // String familyIds = listFamilyIds(); |
| | | // boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | // if (familyIds.contains(",")) { |
| | | // String[] familyList = familyIds.split(","); |
| | | // for (String familyId : familyList) { |
| | | // if (familyId.equals(zfEvent.getFamilyId())) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (zfEvent.getFamilyId().equals(familyIds)) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // if (flag) { |
| | | // if (save(zfEvent)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // throw new RuntimeException("你没有操作该家庭号为" + zfEvent.getFamilyId() + "数据的权限"); |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfEvent zfEvent) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | | if (familyIds.contains(",")) { |
| | | String[] familyList = familyIds.split(","); |
| | | for (String familyId : familyList) { |
| | | if (familyId.equals(zfEvent.getFamilyId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } else { |
| | | if (zfEvent.getFamilyId().equals(familyIds)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (flag) { |
| | | if (save(zfEvent)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfEvent.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfEvent zfEvent) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfEvent.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | if(familyId == null){ |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfEvent.setFamilyId(myFamilyIds[0]); |
| | | } else { |
| | | zfEvent.setFamilyId(myFamilyId); |
| | | 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()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (zfEvent.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | |
| | | if(zfEvent.getFamilyId() == null){ |
| | | //默认添加自己家庭的数据 |
| | | zfEvent.setFamilyId(familyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfEvent> zfEventLambdaQueryWrapper = uniqueCondition(zfEvent); |
| | | List<ZfEvent> list = list(zfEventLambdaQueryWrapper); |
| | | LambdaQueryWrapper<ZfEvent> lqw = uniqueCondition(zfEvent); |
| | | List<ZfEvent> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public AjaxResult addData2(ZfEvent zfEvent) { |
| | | // ZInfoUser mySelf = getMySelf(); |
| | | // String myFamilyId = mySelf.getFamilyId(); |
| | | // |
| | | // if (StringUtils.isNotEmpty(zfEvent.getFamilyId())) { |
| | | // throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | // } |
| | | // |
| | | // if (StringUtils.isEmpty(myFamilyId)) { |
| | | // throw new RuntimeException("您还未加入任何家庭"); |
| | | // } |
| | | // |
| | | // if (myFamilyId.contains(",")) { |
| | | // String[] myFamilyIds = myFamilyId.split(","); |
| | | // //默认添加第一个家庭的数据 |
| | | // zfEvent.setFamilyId(myFamilyIds[0]); |
| | | // } else { |
| | | // zfEvent.setFamilyId(myFamilyId); |
| | | // } |
| | | // |
| | | // //判断是否有重复数据 |
| | | // LambdaQueryWrapper<ZfEvent> zfEventLambdaQueryWrapper = uniqueCondition(zfEvent); |
| | | // List<ZfEvent> list = list(zfEventLambdaQueryWrapper); |
| | | // if(list.size()>0){ |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | // } |
| | | // |
| | | // if (save(zfEvent)) { |
| | | // return AjaxResult.success(); |
| | | // } else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); |
| | | List<ZfEvent> propertyList = null; |
| | | List<ZfEvent> dataList = null; |
| | | try { |
| | | propertyList = util.importExcel(file.getInputStream()); |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("资产列表为:{}", propertyList); |
| | | log.info("数据列表为:{}", dataList); |
| | | |
| | | for (ZfEvent zfEvent : propertyList) { |
| | | zfEventService.addData2(zfEvent); |
| | | for (ZfEvent zfEvent : dataList) { |
| | | zfEventService.addData(zfEvent); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult updateData(ZfEvent zfEvent) { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | Long familyId = myself.getFamilyId(); |
| | | |
| | | //先根据id查询出数据的familyId,看看有没有权限操作 |
| | | Long dataFamilyId = getById(zfEvent.getId()).getFamilyId(); |
| | | |
| | | List<ZAuthority> authority = zAuthorityService.getAuthority(); |
| | | List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) { |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | |
| | | if(updateById(zfEvent)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | List<ZfEvent> dataList = zfEventService.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(EVENT_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList()); |
| | | familyIdList.add(familyId); |
| | | |
| | | for (ZfEvent data : dataList) { |
| | | if (!familyIdList.contains(data.getFamilyId())){ |
| | | throw new RuntimeException("你没有权限操作此家庭的数据"); |
| | | } |
| | | } |
| | | |
| | | if (zfEventService.removeByIds(Arrays.asList(ids))) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.mapper.ZfEventMapper; |
| | | import com.ruoyi.mapper.ZfFamilyMapper; |
| | | import com.ruoyi.service.ZfEventService; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:32 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public class ZfFamilyServiceImpl extends ServiceImpl<ZfFamilyMapper, ZfFamily> implements ZfFamilyService { |
| | | } |
New file |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.domain.ZfRole; |
| | | import com.ruoyi.mapper.ZfFamilyMapper; |
| | | import com.ruoyi.mapper.ZfRoleMapper; |
| | | import com.ruoyi.service.ZfFamilyService; |
| | | import com.ruoyi.service.ZfRoleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author Jinquan_Ou |
| | | * @Description |
| | | * @Date 2023-07-14 14:33 |
| | | * @Version 1.0.0 |
| | | **/ |
| | | @Service |
| | | public class ZfRoleServiceImpl extends ServiceImpl<ZfRoleMapper, ZfRole> implements ZfRoleService { |
| | | } |