|
|
|
|
@@ -5,6 +5,7 @@ import java.util.Arrays;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.limap.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.limap.common.core.domain.entity.SysRole;
|
|
|
|
|
import com.limap.common.utils.StringUtils;
|
|
|
|
|
import com.limap.core.basic.service.IBasicUserWithdrawService;
|
|
|
|
|
@@ -40,6 +41,10 @@ import com.limap.core.basic.vo.SharingRecordSearchVo;
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/basic/sharingRecord")
|
|
|
|
|
public class BasicProfitSharingRecordController extends BaseController {
|
|
|
|
|
private static final String DATA_SCOPE_ALL = "1";
|
|
|
|
|
private static final String DATA_SCOPE_DEPT = "3";
|
|
|
|
|
private static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBasicProfitSharingRecordService basicProfitSharingRecordService;
|
|
|
|
|
@Autowired
|
|
|
|
|
@@ -53,10 +58,7 @@ public class BasicProfitSharingRecordController extends BaseController {
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public TableDataInfo list(BasicProfitSharingRecord basicProfitSharingRecord) {
|
|
|
|
|
startPage();
|
|
|
|
|
List<SysRole> roles = getLoginUser().getUser().getRoles();
|
|
|
|
|
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) <0)){
|
|
|
|
|
basicProfitSharingRecord.setUserId(getUserId());
|
|
|
|
|
}
|
|
|
|
|
applySharingRecordDataScope(basicProfitSharingRecord);
|
|
|
|
|
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
@@ -66,12 +68,7 @@ public class BasicProfitSharingRecordController extends BaseController {
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('basic:sharingRecord:list')")
|
|
|
|
|
@GetMapping("/report")
|
|
|
|
|
public AjaxResult reportData(SharingRecordSearchVo searchVo) {
|
|
|
|
|
List<SysRole> roles = getLoginUser().getUser().getRoles();
|
|
|
|
|
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) >=0)){
|
|
|
|
|
searchVo.setUserId(getUserId());
|
|
|
|
|
}else{
|
|
|
|
|
searchVo.setDeptId(getDeptId());
|
|
|
|
|
}
|
|
|
|
|
applySharingRecordDataScope(searchVo);
|
|
|
|
|
Map<String, Object> resultMap = basicProfitSharingRecordService.getReportData(searchVo);
|
|
|
|
|
return success(resultMap);
|
|
|
|
|
}
|
|
|
|
|
@@ -84,6 +81,7 @@ public class BasicProfitSharingRecordController extends BaseController {
|
|
|
|
|
@Log(title = "分润记录", businessType = BusinessType.EXPORT)
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(HttpServletResponse response, BasicProfitSharingRecord basicProfitSharingRecord) {
|
|
|
|
|
applySharingRecordDataScope(basicProfitSharingRecord);
|
|
|
|
|
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
|
|
|
|
|
ExcelUtil<BasicProfitSharingRecord> util = new ExcelUtil<BasicProfitSharingRecord>(BasicProfitSharingRecord.class);
|
|
|
|
|
util.exportExcel(response, list, "分润记录数据");
|
|
|
|
|
@@ -149,4 +147,40 @@ public class BasicProfitSharingRecordController extends BaseController {
|
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
|
|
return toAjax(basicProfitSharingRecordService.removeByIds(Arrays.asList(ids)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applySharingRecordDataScope(BasicProfitSharingRecord record) {
|
|
|
|
|
SysUser user = getLoginUser().getUser();
|
|
|
|
|
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
|
|
|
|
|
record.getParams().put("scopeType", "deptAndChild");
|
|
|
|
|
record.getParams().put("scopeDeptId", getDeptId());
|
|
|
|
|
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
|
|
|
|
|
record.getParams().put("scopeType", "dept");
|
|
|
|
|
record.getParams().put("scopeDeptId", getDeptId());
|
|
|
|
|
} else {
|
|
|
|
|
record.setUserId(getUserId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applySharingRecordDataScope(SharingRecordSearchVo searchVo) {
|
|
|
|
|
SysUser user = getLoginUser().getUser();
|
|
|
|
|
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
|
|
|
|
|
searchVo.setDeptId(getDeptId());
|
|
|
|
|
searchVo.getParams().put("scopeType", "deptAndChild");
|
|
|
|
|
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
|
|
|
|
|
searchVo.setDeptId(getDeptId());
|
|
|
|
|
searchVo.getParams().put("scopeType", "dept");
|
|
|
|
|
} else {
|
|
|
|
|
searchVo.setUserId(getUserId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasDataScope(List<SysRole> roles, String dataScope) {
|
|
|
|
|
return roles != null && roles.stream().anyMatch(role -> dataScope.equals(role.getDataScope()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|