领料申请和管理数据隔离

This commit is contained in:
liang.chao 2024-02-22 17:02:04 +08:00
parent 7942e4a93d
commit 9ca45416b3
8 changed files with 320 additions and 58 deletions

View File

@ -0,0 +1,101 @@
package com.bonus.sgzb.common.core.utils;
import java.util.List;
/**
* @Author梁超
* @date2024/2/22 - 16:39
*/
public class ListPagingUtil {
private Integer currentPage;//当前页
private Integer pageSize;//每页显示记录条数
private Integer totalPage;//总页数
private Integer star;//开始数据
private Integer total;//总条数
private List<?> rows;//每页显示的数据
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public List<?> getRows() {
return rows;
}
public void setRows(List<?> rows) {
this.rows = rows;
}
public Integer getStar() {
return star;
}
public void setStar(Integer star) {
this.star = star;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
@Override
public String toString() {
return "ListPagingUtil{" +
"currentPage=" + currentPage +
", pageSize=" + pageSize +
", totalPage=" + totalPage +
", rows=" + rows +
", star=" + star +
", total=" + total +
'}';
}
public void pageStartInfo(Integer currentPage, Integer pageSize){
//如果传入的pageNumber为null给pageNumber赋为1
currentPage = currentPage == null ? 1 : currentPage;
//如果传入的pageSize为null给pageSize赋为10
pageSize = pageSize == null ? 10 : pageSize;
this.setCurrentPage(currentPage);
this.setPageSize(pageSize);
}
public static ListPagingUtil paging(Integer currentPage, Integer pageSize, List<?> list) {
ListPagingUtil pagingUtil = new ListPagingUtil();
//初始化
pagingUtil.pageStartInfo(currentPage, pageSize);
//设置起始数据
pagingUtil.setStar((pagingUtil.getCurrentPage()-1)*pagingUtil.getPageSize());
//设置总数
pagingUtil.setTotal(list.size());
//设置总页数
pagingUtil.setTotalPage(pagingUtil.getTotal() % pagingUtil.getPageSize() == 0 ? pagingUtil.getTotal()/pagingUtil.getPageSize() :pagingUtil.getTotal()/pagingUtil.getPageSize()+1);
//截取list
pagingUtil.setRows(list.subList(pagingUtil.getStar(), pagingUtil.getTotal()-pagingUtil.getStar()>pagingUtil.getPageSize()?pagingUtil.getStar()+pagingUtil.getPageSize():pagingUtil.getTotal()));
return pagingUtil;
}
}

View File

@ -7,8 +7,11 @@ import java.util.List;
import com.bonus.sgzb.common.core.constant.HttpStatus;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.PageUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.PageDomain;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.core.web.page.TableSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
@ -17,25 +20,21 @@ import com.github.pagehelper.PageInfo;
/**
* web层通用数据处理
*
*
* @author ruoyi
*/
public class BaseController
{
public class BaseController {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 将前台传递过来的日期格式的字符串自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder)
{
public void initBinder(WebDataBinder binder) {
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
{
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text)
{
public void setAsText(String text) {
setValue(DateUtils.parseDate(text));
}
});
@ -44,25 +43,22 @@ public class BaseController
/**
* 设置请求分页数据
*/
protected void startPage()
{
protected void startPage() {
PageUtils.startPage();
}
/**
* 清理分页的线程变量
*/
protected void clearPage()
{
protected void clearPage() {
PageUtils.clearPage();
}
/**
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list)
{
@SuppressWarnings({"rawtypes", "unchecked"})
protected TableDataInfo getDataTable(List<?> list) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setRows(list);
@ -74,70 +70,62 @@ public class BaseController
/**
* 返回成功
*/
public AjaxResult success()
{
public AjaxResult success() {
return AjaxResult.success();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
public AjaxResult success(String message) {
return AjaxResult.success(message);
}
/**
* 返回成功消息
*/
public AjaxResult success(Object data)
{
public AjaxResult success(Object data) {
return AjaxResult.success(data);
}
/**
* 返回失败消息
*/
public AjaxResult error()
{
public AjaxResult error() {
return AjaxResult.error();
}
/**
* 返回失败消息
*/
public AjaxResult error(String message)
{
public AjaxResult error(String message) {
return AjaxResult.error(message);
}
/**
* 返回警告消息
*/
public AjaxResult warn(String message)
{
public AjaxResult warn(String message) {
return AjaxResult.warn(message);
}
/**
* 响应返回结果
*
*
* @param rows 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows)
{
protected AjaxResult toAjax(int rows) {
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 响应返回结果
*
*
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result)
{
protected AjaxResult toAjax(boolean result) {
return result ? success() : error();
}
}

View File

@ -24,6 +24,55 @@ public class TableDataInfo implements Serializable
/** 消息内容 */
private String msg;
private int pageNum;
private int size;
private int startRow;
private int endRow;
public int getEndRow() {
return endRow;
}
public void setEndRow(int endRow) {
this.endRow = endRow;
}
public int getStartRow() {
return startRow;
}
public void setStartRow(int startRow) {
this.startRow = startRow;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
private int pageSize;
/**
* 表格数据对象
*/

View File

@ -11,6 +11,8 @@ import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
import com.bonus.sgzb.app.service.LeaseApplyInfoService;
import com.bonus.sgzb.app.service.LeaseUserBookService;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.common.core.utils.ListPagingUtil;
import com.bonus.sgzb.common.core.utils.ServletUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
@ -29,6 +31,10 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;
/**
* 任务表(tm_task)表控制层
@ -274,7 +280,7 @@ public class TmTaskController extends BaseController {
/**
* 查询机具领料申请列表
* 查询机具领料申请列表个人
*
* @param task 筛选条件
* @param souceBy app为1 web为0
@ -286,14 +292,26 @@ public class TmTaskController extends BaseController {
if (StringUtils.isNull(task)) {
return AjaxResult.error("参数错误");
}
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
List<TmTask> leaseAuditList = new ArrayList<>();
if (souceBy == 1) {
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(leaseAuditList);
if (roles.contains("admin")){
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}else {
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}
}
startPage();
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
if (roles.contains("admin")){
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}else {
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}
}
/**
@ -314,9 +332,11 @@ public class TmTaskController extends BaseController {
leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
return AjaxResult.success(leaseAuditList);
}
startPage();
// startPage();
leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex,pageSize, leaseAuditList));
}
/**
@ -327,13 +347,19 @@ public class TmTaskController extends BaseController {
@Log(title = "领料申请/管理导出", businessType = BusinessType.EXPORT)
@PostMapping("/applyExport")
public void applyExport(HttpServletResponse response, TmTask task) {
List<TmTask> leaseAuditList = tmTaskService.getLeaseAuditList(task);
List<TmTask> leaseAuditList = new ArrayList<>();
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
// 领料申请导出
if (task.getTypes() == 1) {
//领料申请的数据
if (roles.contains("admin")){
leaseAuditList = tmTaskService.getLeaseAuditList(task);
}else {
leaseAuditList = tmTaskService.getLeaseAuditListByPeople(task);
}
ExcelUtil<TmTask> util = new ExcelUtil<TmTask>(TmTask.class);
util.exportExcel(response, leaseAuditList, "领料申请数据");
} else {
//领料管理的数据
//领料管理导出
List<TmTask> leaseAuditManageList = tmTaskService.getLeaseAuditManageList(task);
List<TmTaskDto> tmTaskDtos = Convert.toList(TmTaskDto.class, leaseAuditManageList);
ExcelUtil<TmTaskDto> util = new ExcelUtil<TmTaskDto>(TmTaskDto.class);

View File

@ -27,6 +27,8 @@ public interface TmTaskMapper {
*/
List<TmTask> getAuditListByLeaseTmTask(@Param("record") TmTask record);
List<TmTask> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTask record);
List<TmTask> getAuditManageListByLeaseTmTask(@Param("record") TmTask record);
List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTask record);

View File

@ -75,4 +75,6 @@ public interface TmTaskService{
LeaseApplyInfo getListSomeol(LeaseApplyInfo info);
List<TmTask> getLeaseAuditListByPeople(TmTask task);
}

View File

@ -1,9 +1,12 @@
package com.bonus.sgzb.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.app.domain.TmTaskDto;
import com.bonus.sgzb.app.mapper.TmTaskMapper;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.common.core.utils.DateUtils;
@ -66,8 +69,10 @@ public class TmTaskServiceImpl implements TmTaskService {
}
List<LeaseApplyInfo> leaseApplyInfo = tmTaskMapper.getLeaseApplyInfo(taskId);
for (LeaseApplyInfo applyInfo : leaseApplyInfo) {
if (applyInfo.getStatus().equals("1") || applyInfo.getStatus().equals("3")) {
num++;
if (applyInfo.getStatus() != null) {
if (applyInfo.getStatus().equals("1") || applyInfo.getStatus().equals("3")) {
num++;
}
}
}
//说明全部审核完成
@ -164,9 +169,7 @@ public class TmTaskServiceImpl implements TmTaskService {
*/
@Override
public List<TmTask> getLeaseAuditList(TmTask record) {
List<TmTask> collect = tmTaskMapper.getAuditListByLeaseTmTask(record);
String username = SecurityUtils.getLoginUser().getUsername();
List<TmTask> tmTaskList = collect.stream().filter(t -> t.getCreateBy().equals(username)).collect(Collectors.toList());
List<TmTask> tmTaskList = tmTaskMapper.getAuditListByLeaseTmTask(record);
for (TmTask tmTask : tmTaskList) {
int count = 0;
if (tmTask != null) {
@ -201,6 +204,49 @@ public class TmTaskServiceImpl implements TmTaskService {
return tmTaskList;
}
/**
* 获取个人申请列表
*/
@Override
public List<TmTask> getLeaseAuditListByPeople(TmTask record) {
String username = SecurityUtils.getLoginUser().getUsername();
record.setCreateBy(username);
List<TmTask> tmTaskList = tmTaskMapper.getAuditListByLeaseTmTaskByPeople(record);
for (TmTask tmTask : tmTaskList) {
int count = 0;
if (tmTask != null) {
// 去查询任务分单表
List<LeaseApplyInfo> auditListByLeaseInfo = tmTaskMapper.getAuditListByLeaseInfo(tmTask);
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo);
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
}
}
}
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
}
// 塞入预领的合计数量
tmTask.setPreCountNum(count);
}
}
return tmTaskList;
}
/**
* 获取领料申请列表
*/
@ -593,27 +639,26 @@ public class TmTaskServiceImpl implements TmTaskService {
TmTask tmTask = tmTaskMapper.getLeaseListTmTask(task);
if (tmTask != null) {
List<LeaseApplyInfo> leaseApplyInfoList = tmTaskMapper.getLeaseListByLeaseInfo(task);
List<LeaseApplyInfo> leaseApplyInfoList2 = tmTaskMapper.getLeaseListByLeaseInfo(task);
tmTask.setLeaseApplyInfoList(leaseApplyInfoList);
/* List<LeaseApplyInfo> leaseApplyInfos = new ArrayList<>();
leaseApplyInfos = ObjectUtil.clone(leaseApplyInfoList);*/
List<LeaseApplyDetails> listLeaseDetails = new ArrayList<>();
for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfoList) {
for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfoList2) {
if (leaseApplyInfo != null) {
/* SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
//获取当前用户所属公司id
Long companyId = sysUser.getCompanyId();*/
//获取当前用户的角色
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
StringBuilder sb = new StringBuilder();
for (String s : roles) {
sb.append(s);
}
String rolesStr = sb.toString();
//如果是内部人员加上所属公司
if ((rolesStr.contains("jjfgs") && !rolesStr.contains("admin"))) {
if ((roles.contains("jjfgs") && !roles.contains("admin"))) {
leaseApplyInfo.setCompanyId(101);
}
//如果是内部人员加上所属公司
if ((rolesStr.contains("tsfgs") && !rolesStr.contains("admin"))) {
if ((roles.contains("tsfgs") && !roles.contains("admin"))) {
leaseApplyInfo.setCompanyId(102);
}
// 去查询领料任务详情表

View File

@ -797,7 +797,56 @@
</select>
<select id="getLeaseApplyInfo" resultType="com.bonus.sgzb.app.domain.LeaseApplyInfo">
SELECT * FROM `lease_apply_info`
WHERE task_id = #{taskId} AND `status` ='1'
WHERE task_id = #{taskId}
</select>
<select id="getAuditListByLeaseTmTaskByPeople" resultType="com.bonus.sgzb.app.domain.TmTask">
SELECT DISTINCT
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,d.`name` as taskName,
case when d.id = '30' then lai.company_audit_remark
when d.id = '31' then lai.dept_audit_remark
when d.id = '32' then lai.direct_audit_remark
when d.id = '98' then lai.company_audit_remark
when d.id = '99' then lai.dept_audit_remark
when d.id = '100' then lai.direct_audit_remark
end examineStatus ,
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
LEFT JOIN sys_user su ON tt.create_by = su.user_name
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1' and tt.create_by = #{record.createBy}
<if test="record.taskId != null and record.taskId != '' ">
AND tt.task_id = #{record.taskId}
</if>
<if test="record.startTime != null and record.startTime != '' and record.endTime != null and record.endTime != '' ">
AND tt.update_time BETWEEN CONCAT(#{record.startTime}, ' 00:00:00') AND CONCAT(#{record.endTime}, ' 23:59:59')
</if>
<if test="record.unitId != null and record.unitId != ''">
AND bui.unit_id = #{record.unitId}
</if>
<if test="record.projectId != null and record.projectId != ''">
AND bpi.pro_id = #{record.projectId}
</if>
<if test="record.keyWord != null and record.keyWord != ''">
AND bai.agreement_code like concat('%', #{record.keyWord}, '%')
</if>
ORDER BY tt.update_time DESC
</select>
</mapper>