| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | private static final String FILE_DELIMETER = ","; |
| | | |
| | | /** |
| | | * 通用下载请求 |
| | | * |
| | | * @param fileName 文件名称 |
| | | * @param delete 是否删除 |
| | | */ |
| | | @GetMapping("/download") |
| | | public void fileDownload(@PathParam("fileName") String fileName, @PathParam("delete") Boolean delete, HttpServletResponse response, HttpServletRequest request) |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.checkAllowDownload(fileName)) |
| | | { |
| | | throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
| | | } |
| | | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | // @GetMapping("/downloadFile") |
| | | // public void fileDownload(@PathParam("path") String path, HttpServletResponse response) |
| | | // { |
| | | // path=path.substring(8); |
| | | // try |
| | | // { |
| | | // if (!FileUtils.checkAllowDownload(path)) |
| | | // { |
| | | // throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", path)); |
| | | // } |
| | | // String realFileName = System.currentTimeMillis() + path.substring(path.indexOf("_") + 1); |
| | | // String filePath = RuoYiConfig.getProfile() + path; |
| | | // |
| | | // response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | // FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | // FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | // |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // log.error("下载文件失败", e); |
| | | // } |
| | | // } |
| | | |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | if (delete) |
| | | { |
| | | FileUtils.deleteFile(filePath); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * 通用下载请求 |
| | | // * |
| | | // * @param fileName 文件名称 |
| | | // * @param delete 是否删除 |
| | | // */ |
| | | // @GetMapping("/download") |
| | | // public void fileDownload(@PathParam("fileName") String fileName, @PathParam("delete") Boolean delete, HttpServletResponse response) |
| | | // { |
| | | // try |
| | | // { |
| | | // if (!FileUtils.checkAllowDownload(fileName)) |
| | | // { |
| | | // throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
| | | // } |
| | | // String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | // String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | // |
| | | // response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | // FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | // FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | // if (delete) |
| | | // { |
| | | // FileUtils.deleteFile(filePath); |
| | | // } |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // log.error("下载文件失败", e); |
| | | // } |
| | | // } |
| | | |
| | | @GetMapping("/downLoadFile") |
| | | public void downLoadFile(@PathParam("path") String path, HttpServletResponse response) throws Exception { |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import com.ruoyi.service.ZfCollectionService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping("/zfCollection") |
| | | public class ZfCollectionController { |
| | | public class ZfCollectionController extends BaseController { |
| | | |
| | | @Autowired |
| | | private ZfCollectionService zfCollectionService; |
| | | |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult listAll(ZfCollection zfCollection){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfCollectionService.selectDataList(zfCollection, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | | * 导出收藏和荣誉记录列表 |
| | | */ |
| | | // @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, "收藏和荣誉记录数据"); |
| | | } |
| | | // |
| | | |
| | | /** |
| | | * 导入收藏和荣誉记录列表 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception |
| | | { |
| | | return zfCollectionService.importExcel(file); |
| | | } |
| | | |
| | | /** |
| | | * 获取收藏和荣誉记录详细信息 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) |
| | | { |
| | | return success(zfCollectionService.getById(id)); |
| | | } |
| | | // |
| | | /** |
| | | * 新增收藏和荣誉记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:add')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfCollection zfCollection) |
| | | { |
| | | return zfCollectionService.addData2(zfCollection); |
| | | } |
| | | |
| | | /** |
| | | * 修改收藏和荣誉记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:edit')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfCollection zfCollection) |
| | | { |
| | | return toAjax(zfCollectionService.updateById(zfCollection)); |
| | | } |
| | | // |
| | | /** |
| | | * 批量删除收藏和荣誉记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:remove')") |
| | | @Log(title = "收藏和荣誉记录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfCollectionService.removeByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.service.ZfEconomyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM; |
| | | import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/zfEconomy") |
| | | public class ZfEconomyController { |
| | | @Slf4j |
| | | public class ZfEconomyController extends BaseController { |
| | | @Autowired |
| | | ZfEconomyService zfEconomyService; |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult listAll(ZfEconomy zfEconomy){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | | Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); |
| | | return zfEconomyService.selectDataList(zfEconomy, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | | * 导出家庭收支台账记录列表 |
| | | */ |
| | | // @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, "家庭收支台账记录数据"); |
| | | } |
| | | // |
| | | |
| | | /** |
| | | * 导入家庭收支台账记录列表 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception |
| | | { |
| | | return zfEconomyService.importExcel(file); |
| | | } |
| | | |
| | | /** |
| | | * 获取家庭收支台账记录详细信息 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) |
| | | { |
| | | return success(zfEconomyService.getById(id)); |
| | | } |
| | | // |
| | | /** |
| | | * 新增家庭收支台账记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:add')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return zfEconomyService.addData2(zfEconomy); |
| | | } |
| | | |
| | | /** |
| | | * 修改家庭收支台账记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:edit')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return toAjax(zfEconomyService.updateById(zfEconomy)); |
| | | } |
| | | // |
| | | /** |
| | | * 批量删除家庭收支台账记录 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:remove')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfEconomyService.removeByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.service.IZfPropertyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | { |
| | | List<ZfProperty> list = zfPropertyService.selectByCondition(zfProperty); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<ZfProperty>(ZfProperty.class); |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | util.exportExcel(response, list, "家庭资产记录数据"); |
| | | } |
| | | // |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfProperty zfProperty) |
| | | { |
| | | return toAjax(zfPropertyService.addProperty(zfProperty)); |
| | | return zfPropertyService.addData2(zfProperty); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi; |
| | | |
| | | import com.ruoyi.domain.ZfDoctor; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.service.ZfDoctorService; |
| | | import com.ruoyi.service.ZfEquipmentService; |
| | | import com.ruoyi.service.ZfEventService; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.service.*; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private ZfEquipmentService zfEquipmentService; |
| | | |
| | | @Autowired |
| | | ZfCollectionService zfCollectionService; |
| | | |
| | | @Autowired |
| | | ZfEconomyService zfEconomyService; |
| | | |
| | | @Test |
| | | public void insert(){ |
| | | public void insert() { |
| | | List<String> people = Arrays.asList("张三,张强,张力", "张萌,张蒙", "张旺,张点,张可", "张章,张常", "张璇,张为,张强,张力"); |
| | | List<String> address = Arrays.asList("花园", "海滩", "公园", "游乐场", "田园", "农庄"); |
| | | |
| | | ZfEvent zfEvent = null; |
| | | |
| | | for (int i = 0; i < 200; i++) { |
| | | zfEvent=new ZfEvent(); |
| | | zfEvent = new ZfEvent(); |
| | | int peopleRandom = new Random().nextInt(5);//0-4的随机数 |
| | | int addressRandom = new Random().nextInt(6);//0-5的随机数 |
| | | |
| | | String base="abcdefghijklmnopqrstuvwxyz"; |
| | | String base = "abcdefghijklmnopqrstuvwxyz"; |
| | | int strRandom1 = new Random().nextInt(16);//0-15的随机数 |
| | | int strRandom2 = new Random().nextInt(16);//0-15的随机数 |
| | | String title=base.substring(strRandom1,strRandom1+8); |
| | | String remark=base.substring(strRandom2,strRandom2+8); |
| | | String title = base.substring(strRandom1, strRandom1 + 8); |
| | | String remark = base.substring(strRandom2, strRandom2 + 8); |
| | | |
| | | zfEvent.setPeople(people.get(peopleRandom)); |
| | | zfEvent.setAddress(address.get(addressRandom)); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | | void insertDoctor(){ |
| | | List<String> l1 = Arrays.asList("牙科", "神经科","外科"); |
| | | void insertDoctor() { |
| | | List<String> l1 = Arrays.asList("牙科", "神经科", "外科"); |
| | | List<String> l2 = Arrays.asList("牙痛", "头痛", "皮肤炎"); |
| | | List<String> l3 = Arrays.asList("一个月", "半个月", "一天"); |
| | | List<String> l4 = Arrays.asList("白芷10g", "中医药1", "中医药2"); |
| | |
| | | List<String> l7 = Arrays.asList("张三", "李四", "王五"); |
| | | List<String> l8 = Arrays.asList("专治牙痛", "专治头痛", "专治皮肤炎"); |
| | | |
| | | ZfDoctor zfDoctor=null; |
| | | int count=0; |
| | | ZfDoctor zfDoctor = null; |
| | | int count = 0; |
| | | for (int i = 0; i < 200; i++) { |
| | | count=count%3; |
| | | zfDoctor=new ZfDoctor(); |
| | | count = count % 3; |
| | | zfDoctor = new ZfDoctor(); |
| | | zfDoctor.setType(l1.get(count)); |
| | | zfDoctor.setSymptom(l2.get(count)); |
| | | zfDoctor.setDuration(l3.get(count)); |
| | |
| | | } |
| | | |
| | | @Test |
| | | void insertEquipment(){ |
| | | List<String> l1 = Arrays.asList("电视", "电冰箱","电脑"); |
| | | void insertEquipment() { |
| | | List<String> l1 = Arrays.asList("电视", "电冰箱", "电脑"); |
| | | List<String> l2 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); |
| | | List<String> l3 = Arrays.asList("张三", "李四", "王五"); |
| | | List<String> l4 = Arrays.asList("夏普液晶电视", "西门子电冰箱", "苹果电脑"); |
| | |
| | | List<String> l6 = Arrays.asList("4k超高清", "双开门", "M2芯片"); |
| | | |
| | | |
| | | ZfEquipment zfEquipment=null; |
| | | int count=0; |
| | | ZfEquipment zfEquipment = null; |
| | | int count = 0; |
| | | for (int i = 0; i < 200; i++) { |
| | | count=count%3; |
| | | zfEquipment=new ZfEquipment(); |
| | | zfEquipment.setName(l1.get(count)); |
| | | zfEquipment.setBuyer(l3.get(count)); |
| | | zfEquipment.setContent(l4.get(count)); |
| | | zfEquipment.setLocation(l5.get(count)); |
| | | zfEquipment.setRemark(l6.get(count)); |
| | | zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); |
| | | count = count % 3; |
| | | zfEquipment = new ZfEquipment(); |
| | | zfEquipment.setName(l1.get(count)); |
| | | zfEquipment.setBuyer(l3.get(count)); |
| | | zfEquipment.setContent(l4.get(count)); |
| | | zfEquipment.setLocation(l5.get(count)); |
| | | zfEquipment.setRemark(l6.get(count)); |
| | | zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); |
| | | count++; |
| | | zfEquipmentService.save(zfEquipment); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | void insertCollection() throws ParseException { |
| | | List<String> l1 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); |
| | | List<String> l2 = Arrays.asList("邮票", "日本军刀", "瓷器"); |
| | | List<String> l3 = Arrays.asList("十二生肖纪念邮票", "天目影打刀", "青花瓷"); |
| | | List<String> l4 = Arrays.asList("购买", "获赠", "拍卖"); |
| | | List<String> l5 = Arrays.asList("张三", "李四", "王五"); |
| | | List<String> l6 = Arrays.asList("10000", "16000", "28000"); |
| | | List<String> l7 = Arrays.asList("床头柜", "酒柜", "客厅电视柜"); |
| | | List<String> l8 = Arrays.asList("十二生肖", "宝刀未老", "古董瓷器"); |
| | | List<String> l9 = Arrays.asList("1", "2", "3", "4"); |
| | | |
| | | Random type = new Random(); |
| | | Random source = new Random(); |
| | | Random own = new Random(); |
| | | Random family = new Random(); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | |
| | | ZfCollection zfCollection = null; |
| | | |
| | | for (int i = 0; i < 50; i++) { |
| | | int typeNum = type.nextInt(3); |
| | | int sourceNum = source.nextInt(3); |
| | | int ownNum = own.nextInt(3); |
| | | // int familyNum = family.nextInt(4); |
| | | |
| | | zfCollection = new ZfCollection(); |
| | | zfCollection.setGetTime(simpleDateFormat.parse(l1.get(typeNum))); |
| | | zfCollection.setType(l2.get(typeNum)); |
| | | zfCollection.setName(l3.get(typeNum)); |
| | | zfCollection.setSource(l4.get(sourceNum)); |
| | | zfCollection.setOwner(l5.get(ownNum)); |
| | | zfCollection.setPrice(l6.get(typeNum)); |
| | | zfCollection.setLocation(l7.get(typeNum)); |
| | | zfCollection.setRemark(l8.get(typeNum)); |
| | | zfCollection.setFamilyId("4"); |
| | | zfCollection.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); |
| | | |
| | | zfCollectionService.save(zfCollection); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | void insertEconomy() throws ParseException { |
| | | List<String> l1 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); |
| | | List<String> l2 = Arrays.asList("-8000", "+10000"); |
| | | List<String> l3 = Arrays.asList("供楼", "存款"); |
| | | List<String> l4 = Arrays.asList("张三", "李四"); |
| | | List<String> l5 = Arrays.asList("20000", "30000"); |
| | | List<Integer> l6 = Arrays.asList(0,1); |
| | | List<String> l9 = Arrays.asList("1", "2", "3", "4"); |
| | | |
| | | Random type = new Random(); |
| | | Random source = new Random(); |
| | | Random own = new Random(); |
| | | Random family = new Random(); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | |
| | | ZfEconomy zfEconomy = null; |
| | | |
| | | for (int i = 0; i < 400; i++) { |
| | | int timeNum = type.nextInt(3); |
| | | int typeNum = source.nextInt(2); |
| | | int ownNum = own.nextInt(3); |
| | | int familyNum = family.nextInt(4); |
| | | |
| | | zfEconomy = new ZfEconomy(); |
| | | zfEconomy.setCreateTime(simpleDateFormat.parse(l1.get(timeNum))); |
| | | zfEconomy.setType(l6.get(typeNum)); |
| | | zfEconomy.setPrice(l2.get(typeNum)); |
| | | zfEconomy.setUseFor(l3.get(typeNum)); |
| | | zfEconomy.setUsePeople(l4.get(typeNum)); |
| | | zfEconomy.setKind(l6.get(typeNum)); |
| | | zfEconomy.setBalance(l5.get(typeNum)); |
| | | zfEconomy.setRemark(l3.get(typeNum)); |
| | | zfEconomy.setFamilyId(l9.get(familyNum)); |
| | | zfEconomy.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); |
| | | |
| | | zfEconomyService.save(zfEconomy); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | public class MenuAuthority { |
| | | |
| | | public static final String PROPERTY_LIST="2007"; |
| | | public static final String COLLECTION_LIST="2018"; |
| | | public static final String ECONOMY_LIST="2023"; |
| | | |
| | | } |
| | |
| | | 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 java.io.Serializable; |
| | | |
| | | /** |
| | |
| | | * @since 2023-03-14 |
| | | */ |
| | | @TableName("z_property") |
| | | @Data |
| | | public class ZProperty implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** |
| | | * 财产类别 |
| | | */ |
| | | @Excel(name = "财产类别",readConverterExp = "1=工资,2=存款,3=理财,4=实业,5=房产,6=证券,7=股票,8=债券,9=期货,10=人身,11=财产保险,12=黄金,13=邮票,14=古玩") |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 收支名称 |
| | | */ |
| | | @Excel(name = "收支名称") |
| | | private String incomeName; |
| | | |
| | | /** |
| | | * 金额 |
| | | */ |
| | | @Excel(name = "金额") |
| | | private Double price; |
| | | |
| | | /** |
| | | * 期限 |
| | | */ |
| | | @Excel(name = "期限") |
| | | private String timeLimit; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 产权 |
| | | */ |
| | | @Excel(name = "产权") |
| | | private String propertyRight; |
| | | |
| | | /** |
| | | * 存放位置 |
| | | */ |
| | | @Excel(name = "存放位置") |
| | | private String location; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @Excel(name = "备注") |
| | | private String remark; |
| | | |
| | | private String url; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | @Excel(name = "是否注销",readConverterExp = "0=正常,1=已注销") |
| | | private Integer status; |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Integer getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Integer userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getIncomeName() { |
| | | return incomeName; |
| | | } |
| | | |
| | | public void setIncomeName(String incomeName) { |
| | | this.incomeName = incomeName; |
| | | } |
| | | |
| | | public Double getPrice() { |
| | | return price; |
| | | } |
| | | |
| | | public void setPrice(Double price) { |
| | | this.price = price; |
| | | } |
| | | |
| | | public String getTimeLimit() { |
| | | return timeLimit; |
| | | } |
| | | |
| | | public void setTimeLimit(String timeLimit) { |
| | | this.timeLimit = timeLimit; |
| | | } |
| | | |
| | | public String getIsChange() { |
| | | return isChange; |
| | | } |
| | | |
| | | public void setIsChange(String isChange) { |
| | | this.isChange = isChange; |
| | | } |
| | | |
| | | public String getPropertyRight() { |
| | | return propertyRight; |
| | | } |
| | | |
| | | public void setPropertyRight(String propertyRight) { |
| | | this.propertyRight = propertyRight; |
| | | } |
| | | |
| | | public String getLocation() { |
| | | return location; |
| | | } |
| | | |
| | | public void setLocation(String location) { |
| | | this.location = location; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ZProperty{" + |
| | | "id=" + id + |
| | | ", userId=" + userId + |
| | | ", type=" + type + |
| | | ", incomeName=" + incomeName + |
| | | ", price=" + price + |
| | | ", timeLimit=" + timeLimit + |
| | | ", isChange=" + isChange + |
| | | ", propertyRight=" + propertyRight + |
| | | ", location=" + location + |
| | | ", remark=" + remark + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @TableName("zf_collection") |
| | | @Data |
| | | @ToString |
| | | public class ZfCollection implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** |
| | | * 获得时间 |
| | | */ |
| | | private LocalDateTime getTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd") |
| | | private Date getTime; |
| | | |
| | | /** |
| | | * 类别 |
| | | */ |
| | | @Excel(name = "类别") |
| | | private String type; |
| | | |
| | | /** |
| | | * 名字 |
| | | */ |
| | | @Excel(name = "名字") |
| | | private String name; |
| | | |
| | | /** |
| | | * 来源 |
| | | */ |
| | | @Excel(name = "来源") |
| | | private String source; |
| | | |
| | | /** |
| | | * 拥有者 |
| | | */ |
| | | @Excel(name = "拥有者") |
| | | private String owner; |
| | | |
| | | /** |
| | | * 价值 |
| | | */ |
| | | private Double price; |
| | | @Excel(name = "价值") |
| | | private String price; |
| | | |
| | | /** |
| | | * 存放位置 |
| | | */ |
| | | @Excel(name = "存放位置") |
| | | private String location; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @Excel(name = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 电子文件路径 |
| | | */ |
| | | private String url; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | /** |
| | | * 所属家庭id |
| | | */ |
| | | @Excel(name = "所属家庭编号") |
| | | private String familyId; |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | public LocalDateTime getGetTime() { |
| | | return getTime; |
| | | } |
| | | |
| | | public void setGetTime(LocalDateTime getTime) { |
| | | this.getTime = getTime; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getSource() { |
| | | return source; |
| | | } |
| | | |
| | | public void setSource(String source) { |
| | | this.source = source; |
| | | } |
| | | |
| | | public String getOwner() { |
| | | return owner; |
| | | } |
| | | |
| | | public void setOwner(String owner) { |
| | | this.owner = owner; |
| | | } |
| | | |
| | | public Double getPrice() { |
| | | return price; |
| | | } |
| | | |
| | | public void setPrice(Double price) { |
| | | this.price = price; |
| | | } |
| | | |
| | | public String getLocation() { |
| | | return location; |
| | | } |
| | | |
| | | public void setLocation(String location) { |
| | | this.location = location; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ZfCollection{" + |
| | | "id=" + id + |
| | | ", getTime=" + getTime + |
| | | ", type=" + type + |
| | | ", name=" + name + |
| | | ", source=" + source + |
| | | ", owner=" + owner + |
| | | ", price=" + price + |
| | | ", location=" + location + |
| | | ", remark=" + remark + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @TableName("zf_economy") |
| | | @Data |
| | | @ToString |
| | | public class ZfEconomy implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | /** |
| | | * 0:基金、1:台账 |
| | | */ |
| | | @Excel(name = "收支类型",readConverterExp = "0=基金,1=台账") |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private LocalDate createTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 收入/支出 |
| | | */ |
| | | private Double price; |
| | | @Excel(name = "收入/支出") |
| | | private String price; |
| | | |
| | | /** |
| | | * 用途 |
| | | */ |
| | | private String use; |
| | | @Excel(name = "用途") |
| | | private String useFor; |
| | | |
| | | /** |
| | | * 使用人 |
| | | */ |
| | | private String user; |
| | | @Excel(name = "使用人") |
| | | private String usePeople; |
| | | |
| | | /** |
| | | * 0:现金,1:自动划扣 |
| | | */ |
| | | @Excel(name = "现金/自动划扣",readConverterExp = "0=现金,1=自动划扣") |
| | | private Integer kind; |
| | | |
| | | /** |
| | | * 余额 |
| | | */ |
| | | private Double balance; |
| | | @Excel(name = "余额") |
| | | private String balance; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @Excel(name = "备注") |
| | | private String remark; |
| | | |
| | | private String url; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | @Excel(name = "所属家庭编号") |
| | | private String familyId; |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(Integer type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public LocalDate getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(LocalDate createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Double getPrice() { |
| | | return price; |
| | | } |
| | | |
| | | public void setPrice(Double price) { |
| | | this.price = price; |
| | | } |
| | | |
| | | public String getUse() { |
| | | return use; |
| | | } |
| | | |
| | | public void setUse(String use) { |
| | | this.use = use; |
| | | } |
| | | |
| | | public String getUser() { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(String user) { |
| | | this.user = user; |
| | | } |
| | | |
| | | public Integer getKind() { |
| | | return kind; |
| | | } |
| | | |
| | | public void setKind(Integer kind) { |
| | | this.kind = kind; |
| | | } |
| | | |
| | | public Double getBalance() { |
| | | return balance; |
| | | } |
| | | |
| | | public void setBalance(Double balance) { |
| | | this.balance = balance; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ZfEconomy{" + |
| | | "id=" + id + |
| | | ", type=" + type + |
| | | ", createTime=" + createTime + |
| | | ", price=" + price + |
| | | ", use=" + use + |
| | | ", user=" + user + |
| | | ", kind=" + kind + |
| | | ", balance=" + balance + |
| | | ", remark=" + remark + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | |
| | | private String url; |
| | | |
| | | @Excel(name = "是否注销",readConverterExp = "0=正常,1=已注销") |
| | | private Integer status; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | /** |
| | | * 家庭id |
| | | */ |
| | | @Excel(name="家庭编号") |
| | | @Excel(name = "所属家庭编号") |
| | | private String familyId; |
| | | |
| | | /** |
| | | * 是否是本家庭的数据(0:不是,1:是) |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer ownData = 0; |
| | | |
| | | @Excel(name = "是否注销",readConverterExp = "0=正常,1=已注销") |
| | | private Integer status; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | AjaxResult selectPropertyList(ZfProperty zfProperty,Integer pageNum,Integer pageSize); |
| | | |
| | | int addProperty(ZfProperty zfProperty); |
| | | AjaxResult addData(ZfProperty zfProperty); |
| | | |
| | | AjaxResult addData2(ZfProperty zfProperty); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface ZfCollectionService extends IService<ZfCollection> { |
| | | |
| | | AjaxResult selectDataList(ZfCollection zfCollection, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfCollection> selectByCondition(ZfCollection zfCollection); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult addData2(ZfCollection zfCollection); |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface ZfEconomyService extends IService<ZfEconomy> { |
| | | |
| | | AjaxResult selectDataList(ZfEconomy zfEconomy, Integer pageNum, Integer pageSize); |
| | | |
| | | List<ZfEconomy> selectByCondition(ZfEconomy zfEconomy); |
| | | |
| | | AjaxResult importExcel(MultipartFile file); |
| | | |
| | | AjaxResult addData2(ZfEconomy zfEconomy); |
| | | } |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.service.DownLoadFileService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | * @Date 2023-03-19 17:33 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class DownLoadFileServiceImpl implements DownLoadFileService { |
| | | |
| | | @Value("${ruoyi.profile}") |
| | | private String basePath; |
| | | |
| | | @Override |
| | | public void downLoadFile(String path, HttpServletResponse response) { |
| | | |
| | | path=basePath+path.substring(8); |
| | | File file = new File(path); |
| | | byte[] buffer = new byte[1024]; |
| | | BufferedInputStream bis = null; |
| | | OutputStream os = null; |
| | | path = path.substring(8); |
| | | try { |
| | | //文件是否存在 |
| | | if (file.exists()) { |
| | | //设置响应 |
| | | response.setContentType("application/octet-stream;charset=UTF-8"); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | response.setHeader("Content-Disposition","attachment;filename="); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | os = response.getOutputStream(); |
| | | bis = new BufferedInputStream(new FileInputStream(file)); |
| | | while(bis.read(buffer) != -1){ |
| | | os.write(buffer); |
| | | } |
| | | if (!FileUtils.checkAllowDownload(path)) { |
| | | throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", path)); |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if(bis != null) { |
| | | bis.close(); |
| | | } |
| | | if(os != null) { |
| | | os.flush(); |
| | | os.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String realFileName = System.currentTimeMillis() + path.substring(path.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getProfile() + path; |
| | | |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.domain.dto.ZfPropertyDto; |
| | | import com.ruoyi.mapper.ZfPropertyMapper; |
| | | import com.ruoyi.service.IZfPropertyService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Service |
| | | public class IZfPropertyServiceImpl extends ServiceImpl<ZfPropertyMapper, ZfProperty> implements IZfPropertyService { |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | |
| | | @Resource |
| | | IZfPropertyService zfPropertyService; |
| | | |
| | | @Override |
| | | public List<ZfProperty> selectByCondition(ZfProperty zfProperty) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lambdaQueryWrapper = buildCondition(zfProperty, familyIds, secondFamilyIds); |
| | | List<ZfProperty> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}", list); |
| | | return list; |
| | | } |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) { |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | |
| | | @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); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, 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()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectPropertyList(ZfProperty zfProperty, Integer pageNum, Integer pageSize) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyAuthority = listSecondFamilyIds(); |
| | |
| | | |
| | | List<ZfProperty> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | List<ZfPropertyDto> dtoResult = beanRecords.stream().map(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | | ZfPropertyDto zfPropertyDto = new ZfPropertyDto(); |
| | | BeanUtils.copyProperties(record, zfPropertyDto); |
| | | |
| | | if (familyIds.contains(",")) { |
| | | String[] familyIdList = familyIds.split(","); |
| | | for (String familyId : familyIdList) { |
| | | if (familyId.equals(recordFamilyId)) { |
| | | zfPropertyDto.setOwnData(1); |
| | | } |
| | | } |
| | | } else { |
| | | if (familyIds.equals(recordFamilyId)) { |
| | | zfPropertyDto.setOwnData(1); |
| | | } |
| | | } |
| | | return zfPropertyDto; |
| | | }).collect(Collectors.toList()); |
| | | List<ZfProperty> dtoResult = markOwnData(familyIds, beanRecords); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public int addProperty(ZfProperty zfProperty) { |
| | | public AjaxResult addData(ZfProperty zfProperty) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | | boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 |
| | |
| | | } |
| | | } |
| | | if (flag) { |
| | | boolean save = save(zfProperty); |
| | | return save ? 1 : 0; |
| | | if (save(zfProperty)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } else { |
| | | throw new RuntimeException("你没有操作该家庭号为" + zfProperty.getFamilyId() + "数据的权限"); |
| | | } |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | |
| | | if (save(zfProperty)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); |
| | | List<ZfProperty> propertyList = null; |
| | |
| | | log.info("资产列表为:{}", propertyList); |
| | | |
| | | for (ZfProperty zfProperty : propertyList) { |
| | | zfPropertyService.addProperty(zfProperty); |
| | | zfPropertyService.addData2(zfProperty); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import com.ruoyi.domain.ZfCollection; |
| | | import com.ruoyi.mapper.ZfCollectionMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCollectionService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.COLLECTION_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ZfCollectionServiceImpl extends ServiceImpl<ZfCollectionMapper, ZfCollection> implements ZfCollectionService { |
| | | |
| | | @Resource |
| | | ZfCollectionService zfCollectionService; |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection) { |
| | | LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>(); |
| | | 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.getOwner()),ZfCollection::getOwner,zfCollection.getOwner()); |
| | | 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.like(zfCollection.getGetTime()!=null,ZfCollection::getGetTime,zfCollection.getGetTime()); |
| | | 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::getId); |
| | | 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); |
| | | List<ZfCollection> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfCollection zfCollection, Integer pageNum, Integer pageSize) { |
| | | 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); |
| | | } |
| | | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | if (save(zfCollection)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfCollection> util = new ExcelUtil<>(ZfCollection.class); |
| | | List<ZfCollection> dataList = null; |
| | | try { |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("准备要导入的数据列表为:{}", dataList); |
| | | |
| | | for (ZfCollection zfCollection : dataList) { |
| | | zfCollectionService.addData2(zfCollection); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.mapper.ZfEconomyMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfEconomyService; |
| | | import com.ruoyi.util.ArraysUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.COLLECTION_LIST; |
| | | import static com.ruoyi.constant.MenuAuthority.ECONOMY_LIST; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ZfEconomyServiceImpl extends ServiceImpl<ZfEconomyMapper, ZfEconomy> implements ZfEconomyService { |
| | | @Resource |
| | | ZfEconomyService zfEconomyService; |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | private LambdaQueryWrapper<ZfEconomy> buildCondition(ZfEconomy zfEconomy) { |
| | | LambdaQueryWrapper<ZfEconomy> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zfEconomy.getType()!=null,ZfEconomy::getType,zfEconomy.getType()); |
| | | lqw.eq(zfEconomy.getKind()!=null,ZfEconomy::getKind,zfEconomy.getKind()); |
| | | lqw.like(zfEconomy.getCreateTime()!=null,ZfEconomy::getCreateTime,zfEconomy.getCreateTime()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getPrice()),ZfEconomy::getPrice,zfEconomy.getPrice()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getUseFor()),ZfEconomy::getUseFor,zfEconomy.getUseFor()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getUsePeople()),ZfEconomy::getUsePeople,zfEconomy.getUsePeople()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getBalance()),ZfEconomy::getBalance,zfEconomy.getBalance()); |
| | | lqw.like(StringUtils.isNotEmpty(zfEconomy.getRemark()),ZfEconomy::getRemark,zfEconomy.getRemark()); |
| | | 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::getId); |
| | | 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); |
| | | List<ZfEconomy> beanRecords = list(lambdaQueryWrapper); |
| | | log.info("从数据库中查到的为:{}", beanRecords); |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | if (save(zfEconomy)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | List<ZfEconomy> dataList = null; |
| | | try { |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("准备要导入的数据列表为:{}", dataList); |
| | | |
| | | for (ZfEconomy zfEconomy : dataList) { |
| | | zfEconomyService.addData2(zfEconomy); |
| | | } |
| | | |
| | | return AjaxResult.success("导入数据成功"); |
| | | |
| | | } |
| | | |
| | | } |