新增记录历史功能

This commit is contained in:
cjw 2024-02-23 10:18:34 +08:00
parent eb461c7868
commit f263f26bda
11 changed files with 475 additions and 6 deletions

View File

@ -0,0 +1,102 @@
package com.ruoyi.mts.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
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.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mts.domain.bo.MesPlanRecordHistoryBo;
import com.ruoyi.mts.domain.vo.MesPlanRecordHistoryVo;
import com.ruoyi.mts.service.IMesPlanRecordHistoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 生产计划明细日期记录历史
*
* @author cjw
* @date 2024-02-23
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/mts/planRecord/history")
public class MesPlanRecordHistoryController extends BaseController {
private final IMesPlanRecordHistoryService iMesPlanRecordHistoryService;
/**
* 查询生产计划明细日期记录历史列表
*/
@SaCheckPermission("mts:planRecordHistory:list")
@GetMapping("/list")
public TableDataInfo<MesPlanRecordHistoryVo> list(MesPlanRecordHistoryBo bo, PageQuery pageQuery) {
return iMesPlanRecordHistoryService.queryPageList(bo, pageQuery);
}
/**
* 导出生产计划明细日期记录历史列表
*/
@SaCheckPermission("mts:planRecordHistory:export")
@Log(title = "生产计划明细日期记录历史", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(MesPlanRecordHistoryBo bo, HttpServletResponse response) {
List<MesPlanRecordHistoryVo> list = iMesPlanRecordHistoryService.queryList(bo);
ExcelUtil.exportExcel(list, "生产计划明细日期记录历史", MesPlanRecordHistoryVo.class, response);
}
/**
* 获取生产计划明细日期记录历史详细信息
*
* @param id 主键
*/
@SaCheckPermission("mts:planRecordHistory:query")
@GetMapping("/{id}")
public R<MesPlanRecordHistoryVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(iMesPlanRecordHistoryService.queryById(id));
}
/**
* 新增生产计划明细日期记录历史
*/
// @SaCheckPermission("mts:planRecordHistory:add")
// @Log(title = "生产计划明细日期记录历史", businessType = BusinessType.INSERT)
// @RepeatSubmit()
// @PostMapping()
// public R<Void> add(@Validated(AddGroup.class) @RequestBody MesPlanRecordHistoryBo bo) {
// return toAjax(iMesPlanRecordHistoryService.insertByBo(bo));
// }
/**
* 修改生产计划明细日期记录历史
*/
// @SaCheckPermission("mts:planRecordHistory:edit")
// @Log(title = "生产计划明细日期记录历史", businessType = BusinessType.UPDATE)
// @RepeatSubmit()
// @PutMapping()
// public R<Void> edit(@Validated(EditGroup.class) @RequestBody MesPlanRecordHistoryBo bo) {
// return toAjax(iMesPlanRecordHistoryService.updateByBo(bo));
// }
/**
* 删除生产计划明细日期记录历史
*
* @param ids 主键串
*/
// @SaCheckPermission("mts:planRecordHistory:remove")
// @Log(title = "生产计划明细日期记录历史", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public R<Void> remove(@NotEmpty(message = "主键不能为空")
// @PathVariable Long[] ids) {
// return toAjax(iMesPlanRecordHistoryService.deleteWithValidByIds(Arrays.asList(ids), true));
// }
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.mts.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* 生产计划明细日期记录历史对象 mes_plan_record_history
*
* @author cjw
* @date 2024-02-23
*/
@Data
//@EqualsAndHashCode(callSuper = true)
@TableName("mes_plan_record_history")
public class MesPlanRecordHistory {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "id")
private Long id;
/**
* 记录id
*/
private Long recordId;
/**
* 记录日期
*/
private Date recordDate;
/**
* 备注
*/
private String remark;
/**
* oss_id
*/
private Long ossId;
private Date createTime;
}

View File

@ -0,0 +1,57 @@
package com.ruoyi.mts.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 java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 生产计划明细日期记录历史业务对象 mes_plan_record_history
*
* @author cjw
* @date 2024-02-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MesPlanRecordHistoryBo extends BaseEntity {
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
private Long id;
/**
* 记录id
*/
@NotNull(message = "记录id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long recordId;
/**
* 记录日期
*/
@NotNull(message = "记录日期不能为空", groups = { AddGroup.class, EditGroup.class })
private Date recordDate;
/**
* 备注
*/
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
private String remark;
/**
* oss_id
*/
@NotNull(message = "oss_id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long ossId;
}

View File

@ -0,0 +1,57 @@
package com.ruoyi.mts.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
import java.io.Serializable;
/**
* 生产计划明细日期记录历史视图对象 mes_plan_record_history
*
* @author cjw
* @date 2024-02-23
*/
@Data
@ExcelIgnoreUnannotated
public class MesPlanRecordHistoryVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long id;
/**
* 记录id
*/
@ExcelProperty(value = "记录id")
private Long recordId;
/**
* 记录日期
*/
@ExcelProperty(value = "记录日期")
private Date recordDate;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
/**
* oss_id
*/
@ExcelProperty(value = "oss_id")
private Long ossId;
}

View File

@ -53,5 +53,7 @@ public class MesPlanRecordVo implements Serializable {
private String ganttColor; private String ganttColor;
private Date createTime;
} }

View File

@ -0,0 +1,15 @@
package com.ruoyi.mts.mapper;
import com.ruoyi.mts.domain.MesPlanRecordHistory;
import com.ruoyi.mts.domain.vo.MesPlanRecordHistoryVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
/**
* 生产计划明细日期记录历史Mapper接口
*
* @author cjw
* @date 2024-02-23
*/
public interface MesPlanRecordHistoryMapper extends BaseMapperPlus<MesPlanRecordHistoryMapper, MesPlanRecordHistory, MesPlanRecordHistoryVo> {
}

View File

@ -0,0 +1,47 @@
package com.ruoyi.mts.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mts.domain.bo.MesPlanRecordHistoryBo;
import com.ruoyi.mts.domain.vo.MesPlanRecordHistoryVo;
import java.util.List;
/**
* 生产计划明细日期记录历史Service接口
*
* @author cjw
* @date 2024-02-23
*/
public interface IMesPlanRecordHistoryService {
/**
* 查询生产计划明细日期记录历史
*/
MesPlanRecordHistoryVo queryById(Long id);
/**
* 查询生产计划明细日期记录历史列表
*/
TableDataInfo<MesPlanRecordHistoryVo> queryPageList(MesPlanRecordHistoryBo bo, PageQuery pageQuery);
/**
* 查询生产计划明细日期记录历史列表
*/
List<MesPlanRecordHistoryVo> queryList(MesPlanRecordHistoryBo bo);
/**
* 新增生产计划明细日期记录历史
*/
Boolean insertByBo(MesPlanRecordHistoryBo bo);
/**
* 修改生产计划明细日期记录历史
*/
// Boolean updateByBo(MesPlanRecordHistoryBo bo);
/**
* 校验并批量删除生产计划明细日期记录历史信息
*/
// Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -50,17 +50,23 @@ public class MesPlanDetailServiceImpl implements IMesPlanDetailService {
@Override @Override
public List<MesPlanDetailVo> queryList(MesPlanDetailBo bo) { public List<MesPlanDetailVo> queryList(MesPlanDetailBo bo) {
bo.setParentId(0L); bo.setParentId(0L);
LambdaQueryWrapper<MesPlanDetail> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<MesPlanDetail> parentQuery = buildQueryWrapper(bo);
List<MesPlanDetailVo> list = baseMapper.selectVoList(lqw); List<MesPlanDetailVo> parentList = baseMapper.selectVoList(parentQuery);
LinkedList<MesPlanDetailVo> res = new LinkedList<>();
for (int i = 0; i < list.size(); i++) {
MesPlanDetailVo vo = list.get(i);
res.add(vo);
//LambdaQueryWrapper<MesPlanDetail> childrenQuery = Wrappers.lambdaQuery(MesPlanDetail.class).ne(TreeEntity::getParentId, 0).orderByAsc(MesPlanDetail::getId);
//List<MesPlanDetailVo> childrenList = baseMapper.selectVoList(childrenQuery);
//Map<Long, List<MesPlanDetailVo>> childrenCollect = childrenList.stream().collect(Collectors.groupingBy(MesPlanDetailVo::getParentId, Collectors.toList()));
LinkedList<MesPlanDetailVo> res = new LinkedList<>();
for (int i = 0; i < parentList.size(); i++) {
MesPlanDetailVo vo = parentList.get(i);
res.add(vo);
LambdaQueryWrapper<MesPlanDetail> voLqw = Wrappers.lambdaQuery(MesPlanDetail.class).eq(TreeEntity::getParentId, vo.getId()).orderByAsc(MesPlanDetail::getId); LambdaQueryWrapper<MesPlanDetail> voLqw = Wrappers.lambdaQuery(MesPlanDetail.class).eq(TreeEntity::getParentId, vo.getId()).orderByAsc(MesPlanDetail::getId);
List<MesPlanDetailVo> children = baseMapper.selectVoList(voLqw); List<MesPlanDetailVo> children = baseMapper.selectVoList(voLqw);
//List<MesPlanDetailVo> children = childrenCollect.get(vo.getId());
if (CollUtil.isNotEmpty(children)) { if (CollUtil.isNotEmpty(children)) {
res.addAll(i + 1, children); res.addAll(i + 1, children);
} }
} }
int size = res.size(); int size = res.size();

View File

@ -0,0 +1,108 @@
package com.ruoyi.mts.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mts.domain.MesPlanRecordHistory;
import com.ruoyi.mts.domain.bo.MesPlanRecordHistoryBo;
import com.ruoyi.mts.domain.vo.MesPlanRecordHistoryVo;
import com.ruoyi.mts.mapper.MesPlanRecordHistoryMapper;
import com.ruoyi.mts.service.IMesPlanRecordHistoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 生产计划明细日期记录历史Service业务层处理
*
* @author cjw
* @date 2024-02-23
*/
@RequiredArgsConstructor
@Service
public class MesPlanRecordHistoryServiceImpl implements IMesPlanRecordHistoryService {
private final MesPlanRecordHistoryMapper baseMapper;
/**
* 查询生产计划明细日期记录历史
*/
@Override
public MesPlanRecordHistoryVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
/**
* 查询生产计划明细日期记录历史列表
*/
@Override
public TableDataInfo<MesPlanRecordHistoryVo> queryPageList(MesPlanRecordHistoryBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<MesPlanRecordHistory> lqw = buildQueryWrapper(bo);
Page<MesPlanRecordHistoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询生产计划明细日期记录历史列表
*/
@Override
public List<MesPlanRecordHistoryVo> queryList(MesPlanRecordHistoryBo bo) {
LambdaQueryWrapper<MesPlanRecordHistory> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<MesPlanRecordHistory> buildQueryWrapper(MesPlanRecordHistoryBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<MesPlanRecordHistory> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getRecordId() != null, MesPlanRecordHistory::getRecordId, bo.getRecordId());
lqw.orderByDesc(MesPlanRecordHistory::getCreateTime);
return lqw;
}
/**
* 新增生产计划明细日期记录历史
*/
@Override
public Boolean insertByBo(MesPlanRecordHistoryBo bo) {
MesPlanRecordHistory add = BeanUtil.toBean(bo, MesPlanRecordHistory.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改生产计划明细日期记录历史
*/
// @Override
// public Boolean updateByBo(MesPlanRecordHistoryBo bo) {
// MesPlanRecordHistory update = BeanUtil.toBean(bo, MesPlanRecordHistory.class);
// validEntityBeforeSave(update);
// return baseMapper.updateById(update) > 0;
// }
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(MesPlanRecordHistory entity) {
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除生产计划明细日期记录历史
*/
// @Override
// public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
// if(isValid){
// //TODO 做一些业务上的校验,判断是否需要校验
// }
// return baseMapper.deleteBatchIds(ids) > 0;
// }
}

View File

@ -8,8 +8,10 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mts.domain.MesPlanRecord; import com.ruoyi.mts.domain.MesPlanRecord;
import com.ruoyi.mts.domain.bo.MesPlanRecordBo; import com.ruoyi.mts.domain.bo.MesPlanRecordBo;
import com.ruoyi.mts.domain.bo.MesPlanRecordHistoryBo;
import com.ruoyi.mts.domain.vo.MesPlanRecordVo; import com.ruoyi.mts.domain.vo.MesPlanRecordVo;
import com.ruoyi.mts.mapper.MesPlanRecordMapper; import com.ruoyi.mts.mapper.MesPlanRecordMapper;
import com.ruoyi.mts.service.IMesPlanRecordHistoryService;
import com.ruoyi.mts.service.IMesPlanRecordService; import com.ruoyi.mts.service.IMesPlanRecordService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,6 +32,8 @@ public class MesPlanRecordServiceImpl implements IMesPlanRecordService {
private final MesPlanRecordMapper baseMapper; private final MesPlanRecordMapper baseMapper;
private final IMesPlanRecordHistoryService historyService;
/** /**
* 查询生产计划明细日期记录 * 查询生产计划明细日期记录
*/ */
@ -97,6 +101,14 @@ public class MesPlanRecordServiceImpl implements IMesPlanRecordService {
public Boolean updateByBo(MesPlanRecordBo bo) { public Boolean updateByBo(MesPlanRecordBo bo) {
MesPlanRecord update = BeanUtil.toBean(bo, MesPlanRecord.class); MesPlanRecord update = BeanUtil.toBean(bo, MesPlanRecord.class);
validEntityBeforeSave(update); validEntityBeforeSave(update);
MesPlanRecordVo recordVo = baseMapper.selectVoById(update.getId());
MesPlanRecordHistoryBo historyBo = new MesPlanRecordHistoryBo();
historyBo.setRecordId(recordVo.getId());
historyBo.setRecordDate(recordVo.getRecordDate());
historyBo.setRemark(recordVo.getRemark());
historyBo.setOssId(recordVo.getOssId());
historyBo.setCreateTime(recordVo.getCreateTime());
historyService.insertByBo(historyBo);
return baseMapper.updateById(update) > 0; return baseMapper.updateById(update) > 0;
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mts.mapper.MesPlanRecordHistoryMapper">
<resultMap type="com.ruoyi.mts.domain.MesPlanRecordHistory" id="MesPlanRecordHistoryResult">
<result property="id" column="id"/>
<result property="recordId" column="record_id"/>
<result property="recordDate" column="record_date"/>
<result property="remark" column="remark"/>
<result property="ossId" column="oss_id"/>
<result property="createTime" column="create_time"/>
</resultMap>
</mapper>