ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventController.java
@@ -67,14 +67,7 @@ @PostMapping("/importData") public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception { ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); List<ZfEvent> eventList = util.importExcel(file.getInputStream()); log.info("家庭大事件列表为:{}",eventList); if (zfEventService.saveBatch(eventList)) { return AjaxResult.success("导入数据成功"); } return AjaxResult.error("导入数据失败"); return zfEventService.importExcel(file); } @@ -96,7 +89,7 @@ @PostMapping public AjaxResult add(@RequestBody ZfEvent zfEvent) { return toAjax(zfEventService.save(zfEvent)); return toAjax(zfEventService.addEvent(zfEvent)); } /** ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyController.java
@@ -69,16 +69,7 @@ @PostMapping("/importData") public AjaxResult importData(@RequestParam("excelImport")MultipartFile file) throws Exception { ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); List<ZfProperty> propertyList = util.importExcel(file.getInputStream()); log.info("资产列表为:{}",propertyList); if (zfPropertyService.saveBatch(propertyList)) { return AjaxResult.success("导入数据成功"); } return AjaxResult.error("导入数据失败"); return zfPropertyService.importExcel(file); } /** @@ -99,7 +90,7 @@ @PostMapping public AjaxResult add(@RequestBody ZfProperty zfProperty) { return toAjax(zfPropertyService.save(zfProperty)); return toAjax(zfPropertyService.addProperty(zfProperty)); } /** ruoyi-admin/src/main/resources/application-druid.yml
@@ -6,8 +6,8 @@ druid: # 主库数据源 master: # url: jdbc:mysql://47.93.189.255:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.93.189.255:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: ZhangApp123! # password: 123456 ruoyi-admin/src/main/resources/application.yml
@@ -70,8 +70,8 @@ # redis 配置 redis: # 地址 host: localhost # host: 192.168.88.68 # host: localhost host: 192.168.88.68 # 端口,默认为6379 port: 6379 # 数据库索引 zhang-content/src/main/java/com/ruoyi/service/IZfPropertyService.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZfProperty; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -19,4 +20,7 @@ AjaxResult selectPropertyList(ZfProperty zfProperty,Integer pageNum,Integer pageSize); int addProperty(ZfProperty zfProperty); AjaxResult importExcel(MultipartFile file); } zhang-content/src/main/java/com/ruoyi/service/ZfEventService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZfEvent; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -20,4 +21,8 @@ AjaxResult selectEventList(ZfEvent zfEvent, Integer pageNum, Integer pageSize); List<ZfEvent> selectByCondition(ZfEvent zfEvent); int addEvent(ZfEvent zfEvent); AjaxResult importExcel(MultipartFile file); } zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java
@@ -8,7 +8,9 @@ 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.ZfProperty; import com.ruoyi.domain.ZfEvent; import com.ruoyi.domain.ZfProperty; import com.ruoyi.mapper.ZfPropertyMapper; @@ -16,6 +18,7 @@ import com.ruoyi.service.ZInfoUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.text.ParseException; @@ -39,6 +42,9 @@ @Resource ZInfoUserService zInfoUserService; @Resource IZfPropertyService zfPropertyService; @Override public List<ZfProperty> selectByCondition(ZfProperty zfProperty) { @@ -94,6 +100,50 @@ } @Override public int addProperty(ZfProperty zfProperty) { String familyIds = listFamilyIds(); boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 if (familyIds.contains(",")) { String[] familyList = familyIds.split(","); for (String familyId : familyList) { if (familyId.equals(zfProperty.getFamilyId())) { flag = true; } } } else { if (zfProperty.getFamilyId().equals(familyIds)) { flag = true; } } if (flag) { boolean save = save(zfProperty); return save ? 1 : 0; } else { throw new RuntimeException("你没有操作该家庭号为" + zfProperty.getFamilyId() + "数据的权限"); } } @Override public AjaxResult importExcel(MultipartFile file) { ExcelUtil<ZfProperty> util = new ExcelUtil<>(ZfProperty.class); List<ZfProperty> propertyList = null; try { propertyList = util.importExcel(file.getInputStream()); } catch (Exception e) { throw new RuntimeException(e); } log.info("资产列表为:{}", propertyList); for (ZfProperty zfProperty : propertyList) { zfPropertyService.addProperty(zfProperty); } return AjaxResult.success("导入数据成功"); } } zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
@@ -9,13 +9,16 @@ 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.ZfEvent; import com.ruoyi.domain.ZfEvent; import com.ruoyi.mapper.ZfEventMapper; import com.ruoyi.service.ZInfoUserService; import com.ruoyi.service.ZfEventService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.HashMap; @@ -35,6 +38,9 @@ @Resource ZInfoUserService zInfoUserService; @Resource ZfEventService zfEventService; private String listFamilyIds(){ SysUser user = SecurityUtils.getLoginUser().getUser(); @@ -68,6 +74,48 @@ return list; } @Override public int addEvent(ZfEvent zfEvent) { String familyIds = listFamilyIds(); boolean flag = false;//判断当前用户的id是否有权加入当前家庭id的对象 if (familyIds.contains(",")) { String[] familyList = familyIds.split(","); for (String familyId : familyList) { if (familyId.equals(zfEvent.getFamilyId())) { flag = true; } } } else { if (zfEvent.getFamilyId().equals(familyIds)) { flag = true; } } if (flag) { boolean save = save(zfEvent); return save ? 1 : 0; } else { throw new RuntimeException("你没有操作该家庭号为" + zfEvent.getFamilyId() + "数据的权限"); } } @Override public AjaxResult importExcel(MultipartFile file) { ExcelUtil<ZfEvent> util = new ExcelUtil<>(ZfEvent.class); List<ZfEvent> eventList = null; try { eventList = util.importExcel(file.getInputStream()); } catch (Exception e) { throw new RuntimeException(e); } log.info("资产列表为:{}", eventList); for (ZfEvent zfEvent : eventList) { zfEventService.addEvent(zfEvent); } return AjaxResult.success("导入数据成功"); } private LambdaQueryWrapper<ZfEvent> buildCondition(ZfEvent zfEvent) { LambdaQueryWrapper<ZfEvent> lqw = new LambdaQueryWrapper<>(); lqw.like(!StringUtils.isEmpty(zfEvent.getAddress()),ZfEvent::getAddress,zfEvent.getAddress());