diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageController.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageController.java index b585627..1629b56 100644 --- a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageController.java +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageController.java @@ -1,27 +1,28 @@ package com.bonus.bmw.controller; + import com.bonus.bmw.domain.po.HomePagePo; import com.bonus.bmw.domain.vo.CommonSetBean; import com.bonus.bmw.service.HomePageService; -import com.bonus.common.core.domain.R; +import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.log.annotation.SysLog; -import com.bonus.common.log.enums.BusinessType; import com.bonus.common.log.enums.OperaType; import com.bonus.common.security.annotation.InnerAuth; import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth; import com.bonus.common.security.utils.SecurityUtils; -import com.bonus.system.api.domain.SysMenu; -import org.springframework.validation.annotation.Validated; +import org.apache.commons.beanutils.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.beans.factory.annotation.Autowired; - +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import static com.bonus.bmw.utils.OwnPermissionUtil.dealWithPermission; + /** * 首页 * @author fly @@ -45,6 +46,13 @@ public class HomePageController extends BaseController { @SysLog(title = "数据概览", businessType = OperaType.QUERY, logType = 0, module = "首页->数据概览", details = "数据概览") public AjaxResult getDataOverview(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + BeanUtils.populate(o, map); + } + } return service.getDataOverview(o); } catch (Exception e) { logger.error(e.toString(), e); @@ -62,6 +70,13 @@ public class HomePageController extends BaseController { @SysLog(title = "人员考勤", businessType = OperaType.QUERY, logType = 0, module = "首页->人员考勤", details = "人员考勤") public AjaxResult getWorkerAtt(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + BeanUtils.populate(o, map); + } + } return service.getWorkerAtt(o); } catch (Exception e) { logger.error(e.toString(), e); @@ -79,6 +94,13 @@ public class HomePageController extends BaseController { @SysLog(title = "工程信息", businessType = OperaType.QUERY, logType = 0, module = "首页->工程信息", details = "工程信息") public AjaxResult getProjectMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + BeanUtils.populate(o, map); + } + } return service.getProjectMsg(o); } catch (Exception e) { logger.error(e.toString(), e); @@ -96,6 +118,13 @@ public class HomePageController extends BaseController { @SysLog(title = "在场人员", businessType = OperaType.QUERY, logType = 0, module = "首页->在场人员", details = "在场人员") public AjaxResult getEinWorkerDistribution(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + BeanUtils.populate(o, map); + } + } return service.getEinWorkerDistribution(o); } catch (Exception e) { logger.error(e.toString(), e); diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageSubController.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageSubController.java index 412fdc1..6f3f2db 100644 --- a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageSubController.java +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/HomePageSubController.java @@ -3,6 +3,7 @@ package com.bonus.bmw.controller; import com.bonus.bmw.domain.po.HomePagePo; import com.bonus.bmw.domain.vo.*; import com.bonus.bmw.service.HomePageSubService; +import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; @@ -14,14 +15,20 @@ import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +import static com.bonus.bmw.utils.OwnPermissionUtil.dealWithPermission; + /** * 首页 - 子页面 * @author fly @@ -45,6 +52,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "总工程详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "总工程详情") public TableDataInfo getMainProMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getMainProMsg(o); return getDataTable(list); @@ -64,6 +78,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "工程详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "工程详情") public TableDataInfo getProMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getProMsg(o); return getDataTable(list); @@ -83,6 +104,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "分包详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "分包详情") public TableDataInfo getSubMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getSubMsg(o); return getDataTable(list); @@ -103,6 +131,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "班组详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "班组详情") public TableDataInfo getTeamMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getTeamMsg(o); return getDataTable(list); @@ -123,6 +158,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "人员详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "人员详情") public TableDataInfo getWorkerMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getWorkerMsg(o); return getDataTable(list); @@ -142,6 +184,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "出场未结算详情", businessType = OperaType.QUERY, logType = 0, module = "首页->二级页面", details = "出场未结算详情") public TableDataInfo getWorkerNotFileMsg(HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } startPage(); List list = service.getWorkerNotFileMsg(o); return getDataTable(list); @@ -195,6 +244,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "总工程导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "总工程导出") public void mainProExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getMainProMsg(o); List exportList = list.stream() .map(worker -> { @@ -218,6 +274,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "标段工程导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "标段工程导出") public void proExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getProMsg(o); List exportList = list.stream() .map(worker -> { @@ -241,6 +304,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "分包单位导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "分包单位导出") public void subExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getSubMsg(o); List exportList = list.stream() .map(worker -> { @@ -264,6 +334,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "班组导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "班组导出") public void teamExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getTeamMsg(o); List exportList = list.stream() .map(worker -> { @@ -288,6 +365,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "人员导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "人员导出") public void workerExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getWorkerMsg(o); List exportList = list.stream() .map(worker -> { @@ -312,6 +396,13 @@ public class HomePageSubController extends BaseController { @SysLog(title = "出场未结算导出", businessType = OperaType.EXPORT, logType = 0, module = "首页->二级页面", details = "出场未结算导出") public void workerNoFileExport(HttpServletResponse response, HomePagePo o) { try { + if(StringUtils.isNotEmpty(Collections.singleton(o.getSubComId()))){ + Map map = dealWithPermission(); + if(!map.isEmpty()){ + // 3. 将 map 中的值复制到 o 对象中 + org.apache.commons.beanutils.BeanUtils.populate(o, map); + } + } List list = service.getWorkerNotFileMsg(o); List exportList = list.stream() .map(worker -> { diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/utils/OwnPermissionUtil.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/utils/OwnPermissionUtil.java index 4bd1323..d7b1433 100644 --- a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/utils/OwnPermissionUtil.java +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/utils/OwnPermissionUtil.java @@ -12,7 +12,8 @@ public class OwnPermissionUtil { Map map=new HashMap<>(); SysUser sysUser = SecurityUtils.getLoginUser().getSysUser(); if("公司级".equals(sysUser.getRoleLevel())){ - map.put("comId",sysUser.getCompanyId().toString()); +// map.put("comId",sysUser.getCompanyId().toString()); + map.put("comId",""); }else if("分公司级".equals(sysUser.getRoleLevel())){ map.put("subComId", sysUser.getBandId()); }else if("项目部级".equals(sysUser.getRoleLevel())){