新增项目报工
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
package com.ruoyi.oa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
|
||||
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
|
||||
import com.ruoyi.oa.service.IOaProjectReportService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 项目报工
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/oa/projectReport")
|
||||
public class OaProjectReportController extends BaseController {
|
||||
|
||||
private final IOaProjectReportService iOaProjectReportService;
|
||||
|
||||
/**
|
||||
* 查询项目报工列表
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<OaProjectReportVo> list(OaProjectReportBo bo, PageQuery pageQuery) {
|
||||
return iOaProjectReportService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出项目报工列表
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:export")
|
||||
@Log(title = "项目报工", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(OaProjectReportBo bo, HttpServletResponse response) {
|
||||
List<OaProjectReportVo> list = iOaProjectReportService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "项目报工", OaProjectReportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目报工详细信息
|
||||
*
|
||||
* @param reportId 主键
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:query")
|
||||
@GetMapping("/{reportId}")
|
||||
public R<OaProjectReportVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long reportId) {
|
||||
return R.ok(iOaProjectReportService.queryById(reportId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目报工
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:add")
|
||||
@Log(title = "项目报工", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaProjectReportBo bo) {
|
||||
return toAjax(iOaProjectReportService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目报工
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:edit")
|
||||
@Log(title = "项目报工", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaProjectReportBo bo) {
|
||||
return toAjax(iOaProjectReportService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目报工
|
||||
*
|
||||
* @param reportIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("oa:projectReport:remove")
|
||||
@Log(title = "项目报工", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{reportIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] reportIds) {
|
||||
return toAjax(iOaProjectReportService.deleteWithValidByIds(Arrays.asList(reportIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.oa.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 项目报工对象 oa_project_report
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("oa_project_report")
|
||||
public class OaProjectReport extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键 ID
|
||||
*/
|
||||
@TableId(value = "report_id")
|
||||
private Long reportId;
|
||||
/**
|
||||
* 经办人
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 工作地点
|
||||
*/
|
||||
private String workPlace;
|
||||
/**
|
||||
* 项目 ID
|
||||
*/
|
||||
private Long projectId;
|
||||
/**
|
||||
* 报工内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 删除标志 (0 正常, 1 删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否出差
|
||||
*/
|
||||
private Long isTrip;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.ruoyi.oa.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 项目报工业务对象 oa_project_report
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OaProjectReportBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键 ID
|
||||
*/
|
||||
private Long reportId;
|
||||
|
||||
/**
|
||||
* 经办人
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 工作地点
|
||||
*/
|
||||
private String workPlace;
|
||||
|
||||
/**
|
||||
* 项目 ID
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 报工内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否出差
|
||||
*/
|
||||
private Long isTrip;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String projectNum;
|
||||
|
||||
/**
|
||||
* 项目代号
|
||||
*/
|
||||
private String projectCode;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.oa.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 项目报工视图对象 oa_project_report
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class OaProjectReportVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键 ID
|
||||
*/
|
||||
@ExcelProperty(value = "主键 ID")
|
||||
private Long reportId;
|
||||
|
||||
/**
|
||||
* 经办人
|
||||
*/
|
||||
@ExcelProperty(value = "经办人")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 经办人姓名
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 工作地点
|
||||
*/
|
||||
@ExcelProperty(value = "工作地点")
|
||||
private String workPlace;
|
||||
|
||||
/**
|
||||
* 项目 ID
|
||||
*/
|
||||
@ExcelProperty(value = "项目 ID")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String projectNum;
|
||||
|
||||
/**
|
||||
* 项目代号
|
||||
*/
|
||||
private String projectCode;
|
||||
|
||||
/**
|
||||
* 报工内容
|
||||
*/
|
||||
@ExcelProperty(value = "报工内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否出差
|
||||
*/
|
||||
private Long isTrip;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ruoyi.oa.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.oa.domain.OaProjectReport;
|
||||
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 项目报工Mapper接口
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
public interface OaProjectReportMapper extends BaseMapperPlus<OaProjectReportMapper, OaProjectReport, OaProjectReportVo> {
|
||||
|
||||
Page<OaProjectReportVo> selectVoPagePlus(@Param("build") Page<Object> build, @Param(Constants.WRAPPER) QueryWrapper<OaProjectReport> lqw);
|
||||
|
||||
OaProjectReportVo selectVoByIdPlus(@Param("reportId") Long reportId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.oa.domain.OaProjectReport;
|
||||
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
|
||||
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目报工Service接口
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
public interface IOaProjectReportService {
|
||||
|
||||
/**
|
||||
* 查询项目报工
|
||||
*/
|
||||
OaProjectReportVo queryById(Long reportId);
|
||||
|
||||
/**
|
||||
* 查询项目报工列表
|
||||
*/
|
||||
TableDataInfo<OaProjectReportVo> queryPageList(OaProjectReportBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询项目报工列表
|
||||
*/
|
||||
List<OaProjectReportVo> queryList(OaProjectReportBo bo);
|
||||
|
||||
/**
|
||||
* 新增项目报工
|
||||
*/
|
||||
Boolean insertByBo(OaProjectReportBo bo);
|
||||
|
||||
/**
|
||||
* 修改项目报工
|
||||
*/
|
||||
Boolean updateByBo(OaProjectReportBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除项目报工信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
|
||||
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
|
||||
import com.ruoyi.oa.domain.OaProjectReport;
|
||||
import com.ruoyi.oa.mapper.OaProjectReportMapper;
|
||||
import com.ruoyi.oa.service.IOaProjectReportService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 项目报工Service业务层处理
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class OaProjectReportServiceImpl implements IOaProjectReportService {
|
||||
|
||||
private final OaProjectReportMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询项目报工
|
||||
*/
|
||||
@Override
|
||||
public OaProjectReportVo queryById(Long reportId){
|
||||
return baseMapper.selectVoByIdPlus(reportId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询项目报工列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<OaProjectReportVo> queryPageList(OaProjectReportBo bo, PageQuery pageQuery) {
|
||||
QueryWrapper<OaProjectReport> lqw = buildQueryWrapper(bo);
|
||||
Page<OaProjectReportVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询项目报工列表
|
||||
*/
|
||||
@Override
|
||||
public List<OaProjectReportVo> queryList(OaProjectReportBo bo) {
|
||||
QueryWrapper<OaProjectReport> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private QueryWrapper<OaProjectReport> buildQueryWrapper(OaProjectReportBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
QueryWrapper<OaProjectReport> lqw = Wrappers.query();
|
||||
lqw.eq(bo.getUserId()!=null, "opr.user_id", bo.getUserId());
|
||||
|
||||
lqw.eq(bo.getProjectId() != null, "opr.project_id", bo.getProjectId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getNickName()), "su.nick_name", bo.getNickName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProjectNum()), "op.project_num", bo.getProjectNum());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProjectCode()), "op.project_code", bo.getProjectCode());
|
||||
lqw.eq(bo.getDeptId()!=null, "su.dept_id", bo.getDeptId());
|
||||
if (bo.getCreateTime() != null) {
|
||||
LocalDateTime start = bo.getCreateTime() // LocalDateTime / Date 都行
|
||||
.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDate() // 先取日期
|
||||
.atStartOfDay(); // 00:00:00
|
||||
LocalDateTime end = start.plusDays(1); // 下一天 00:00:00
|
||||
|
||||
lqw.ge("opr.create_time", start)
|
||||
.lt("opr.create_time", end); // [start, end)
|
||||
}
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目报工
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(OaProjectReportBo bo) {
|
||||
OaProjectReport add = BeanUtil.toBean(bo, OaProjectReport.class);
|
||||
validEntityBeforeSave(add);
|
||||
add.setUserId(LoginHelper.getUserId());
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setReportId(add.getReportId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目报工
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(OaProjectReportBo bo) {
|
||||
OaProjectReport update = BeanUtil.toBean(bo, OaProjectReport.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(OaProjectReport entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除项目报工
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,6 @@ public class SysOssAclServiceImpl extends ServiceImpl<SysOssAclMapper, SysOssAcl
|
||||
|
||||
/* 3. 批量查询用户表 */
|
||||
List<SysUser> users = userMapper.selectBatchIds(userIds);
|
||||
System.out.println(users);
|
||||
/* 4. 转成 DTO */
|
||||
return users.stream().map(u -> {
|
||||
SysUserVo dto = new SysUserVo();
|
||||
|
||||
Reference in New Issue
Block a user