From 8e3f58c38fd3d552125ada6afdf88e7fc2b380a0 Mon Sep 17 00:00:00 2001 From: Jinquan_Ou <Jinquan@gdut.com> Date: 星期一, 17 四月 2023 12:47:32 +0800 Subject: [PATCH] 888 --- zhang-content/src/main/java/com/ruoyi/service/ZfEconomyService.java | 11 ruoyi-admin/src/test/java/com/ruoyi/insertData.java | 152 ++++- ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java | 88 ++- ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java | 8 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEconomyController.java | 102 +++ zhang-content/src/main/java/com/ruoyi/domain/ZfEconomy.java | 122 +--- zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java | 4 zhang-content/src/main/java/com/ruoyi/service/ZfCollectionService.java | 11 zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java | 109 ++- /dev/null | 78 -- zhang-content/src/main/java/com/ruoyi/service/impl/ZfEconomyServiceImpl.java | 258 +++++++++ zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java | 5 zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java | 52 - zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java | 258 +++++++++ zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java | 2 zhang-content/src/main/java/com/ruoyi/domain/ZfCollection.java | 119 +--- zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java | 107 --- zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java | 11 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfCollectionController.java | 104 +++ 19 files changed, 1,113 insertions(+), 488 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index 6c13276..16033c1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -11,6 +11,7 @@ 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; @@ -41,37 +42,64 @@ 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 { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfCollectionController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfCollectionController.java index f3708e4..73aa728 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfCollectionController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfCollectionController.java @@ -1,9 +1,26 @@ package com.ruoyi.web.controller.zhang; -import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.domain.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> @@ -14,8 +31,89 @@ * @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))); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEconomyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEconomyController.java index 6329b58..4835abe 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEconomyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEconomyController.java @@ -1,9 +1,26 @@ package com.ruoyi.web.controller.zhang; -import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.domain.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> @@ -15,7 +32,86 @@ */ @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))); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java index 5cde8b7..cd2cfa9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java @@ -3,15 +3,11 @@ 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; @@ -55,7 +51,7 @@ { 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, "瀹跺涵璧勪骇璁板綍鏁版嵁"); } // @@ -88,7 +84,7 @@ @PostMapping public AjaxResult add(@RequestBody ZfProperty zfProperty) { - return toAjax(zfPropertyService.addProperty(zfProperty)); + return zfPropertyService.addData2(zfProperty); } /** diff --git a/ruoyi-admin/src/test/java/com/ruoyi/insertData.java b/ruoyi-admin/src/test/java/com/ruoyi/insertData.java index 4f7d505..2c4e2a3 100644 --- a/ruoyi-admin/src/test/java/com/ruoyi/insertData.java +++ b/ruoyi-admin/src/test/java/com/ruoyi/insertData.java @@ -1,15 +1,13 @@ 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; @@ -32,23 +30,29 @@ @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)); @@ -59,9 +63,10 @@ } } + @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"); @@ -70,11 +75,11 @@ 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)); @@ -90,8 +95,8 @@ } @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("澶忔櫘娑叉櫠鐢佃", "瑗块棬瀛愮數鍐扮", "鑻规灉鐢佃剳"); @@ -99,22 +104,111 @@ 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); + } + + + } } + + + diff --git a/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java b/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java index 2cd7b86..bb888ac 100644 --- a/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java +++ b/zhang-content/src/main/java/com/ruoyi/constant/MenuAuthority.java @@ -9,5 +9,7 @@ public class MenuAuthority { public static final String PROPERTY_LIST="2007"; + public static final String COLLECTION_LIST="2018"; + public static final String ECONOMY_LIST="2023"; } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java b/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java index 6e27dda..9709e07 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java @@ -3,6 +3,9 @@ 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; /** @@ -14,6 +17,7 @@ * @since 2023-03-14 */ @TableName("z_property") +@Data public class ZProperty implements Serializable { private static final long serialVersionUID = 1L; @@ -29,21 +33,25 @@ /** * 璐骇绫诲埆 */ + @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; /** @@ -54,112 +62,25 @@ /** * 浜ф潈 */ + @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=姝e父,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 + - "}"; - } } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfCollection.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfCollection.java index f3037cb..1ed6f7b 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfCollection.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfCollection.java @@ -1,10 +1,17 @@ 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> @@ -15,6 +22,8 @@ * @since 2023-03-12 */ @TableName("zf_collection") +@Data +@ToString public class ZfCollection implements Serializable { private static final long serialVersionUID = 1L; @@ -25,128 +34,68 @@ /** * 鑾峰緱鏃堕棿 */ - 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; - } + /** + * 鎵�灞炲搴璱d + */ + @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 + - "}"; - } } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfEconomy.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfEconomy.java index 4c3ec67..9683148 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfEconomy.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfEconomy.java @@ -1,10 +1,17 @@ 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> @@ -15,138 +22,73 @@ * @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 + - "}"; - } } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java index f42490b..b7448fe 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfEquipment.java @@ -1,6 +1,7 @@ package com.ruoyi.domain; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -73,5 +74,9 @@ private String url; + @Excel(name = "鏄惁娉ㄩ攢",readConverterExp = "0=姝e父,1=宸叉敞閿�") + private Integer status; + + } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java index f1b7e6a..1989f69 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java @@ -65,8 +65,17 @@ /** * 瀹跺涵id */ - @Excel(name="瀹跺涵缂栧彿") + @Excel(name = "鎵�灞炲搴紪鍙�") private String familyId; + /** + * 鏄惁鏄湰瀹跺涵鐨勬暟鎹�(0:涓嶆槸,1:鏄�) + */ + @TableField(exist = false) + private Integer ownData = 0; + + @Excel(name = "鏄惁娉ㄩ攢",readConverterExp = "0=姝e父,1=宸叉敞閿�") + private Integer status; + } diff --git a/zhang-content/src/main/java/com/ruoyi/domain/dto/ZfPropertyDto.java b/zhang-content/src/main/java/com/ruoyi/domain/dto/ZfPropertyDto.java deleted file mode 100644 index ac4fec5..0000000 --- a/zhang-content/src/main/java/com/ruoyi/domain/dto/ZfPropertyDto.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.ruoyi.domain.dto; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.annotation.Excel; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * @Author Jinquan_Ou - * @Description - * @Date 2023-04-12 20:54 - * @Version 1.0.0 - **/ - -@Data -public class ZfPropertyDto implements Serializable { - private static final long serialVersionUID = 1L; - - - private Integer id; - - /** - * 璧勪骇绫诲瀷 - */ - - private String type; - - /** - * 鏍囬(璐﹀彿銆佸崱鍙�) - */ - - private String title; - - /** - * 寮�鎴疯(璧勪骇鍦板潃) - */ - - private String location; - - /** - * 鎸佹湁浜哄悕瀛� - */ - - private String holder; - - /** - * 瀛樻斁鍦板潃 - */ - - private String address; - - - private String remark; - - /** - * 鍒涘缓鏃堕棿 - */ - @JsonFormat(pattern = "yyyy-MM-dd") - private Date createTime; - - private String url; - - /** - * 鏈潯鏁版嵁鎵�灞炰簬鐨勫搴� - */ - private String familyId; - - /** - * 鏄惁鏄湰瀹跺涵鐨勬暟鎹�(0:涓嶆槸,1:鏄�) - */ - private Integer ownData = 0; - - -} diff --git a/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java index b68eaa9..448bad5 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java @@ -20,7 +20,9 @@ AjaxResult selectPropertyList(ZfProperty zfProperty,Integer pageNum,Integer pageSize); - int addProperty(ZfProperty zfProperty); + AjaxResult addData(ZfProperty zfProperty); + + AjaxResult addData2(ZfProperty zfProperty); AjaxResult importExcel(MultipartFile file); } diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfCollectionService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfCollectionService.java index 155d0e1..4b84d99 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/ZfCollectionService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/ZfCollectionService.java @@ -2,7 +2,11 @@ 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> @@ -14,4 +18,11 @@ */ 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); } diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfEconomyService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfEconomyService.java index c49d960..73ea5cb 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/ZfEconomyService.java +++ b/zhang-content/src/main/java/com/ruoyi/service/ZfEconomyService.java @@ -2,7 +2,11 @@ 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> @@ -14,4 +18,11 @@ */ 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); } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java index 866a6b5..e041bbd 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java @@ -1,8 +1,13 @@ 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; @@ -14,47 +19,26 @@ * @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); } } } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java index 92428e1..d1c5af7 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java @@ -12,13 +12,13 @@ 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; @@ -38,21 +38,15 @@ @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<>(); @@ -189,6 +183,34 @@ } @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(); @@ -199,32 +221,14 @@ 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;//鍒ゆ柇褰撳墠鐢ㄦ埛鐨刬d鏄惁鏈夋潈鍔犲叆褰撳墠瀹跺涵id鐨勫璞� @@ -241,14 +245,49 @@ } } 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; @@ -260,7 +299,7 @@ log.info("璧勪骇鍒楄〃涓猴細{}", propertyList); for (ZfProperty zfProperty : propertyList) { - zfPropertyService.addProperty(zfProperty); + zfPropertyService.addData2(zfProperty); } return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛"); diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java index 2ab67fa..5a26611 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java @@ -1,11 +1,33 @@ 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> @@ -16,6 +38,242 @@ * @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(); + + //澶勭悊浼犲叆鐨剆econdFamilyAuthority 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); + } + } + } + //灏哠tringBuffer杞垚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("瀵煎叆鏁版嵁鎴愬姛"); + + } + } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEconomyServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEconomyServiceImpl.java index f26764d..21a607b 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEconomyServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEconomyServiceImpl.java @@ -1,11 +1,34 @@ 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> @@ -16,6 +39,241 @@ * @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(); + + //澶勭悊浼犲叆鐨剆econdFamilyAuthority 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); + } + } + } + //灏哠tringBuffer杞垚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("瀵煎叆鏁版嵁鎴愬姛"); + + } } -- Gitblit v1.9.1