diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/controller/MesPlanRecordHistoryController.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/controller/MesPlanRecordHistoryController.java new file mode 100644 index 0000000..3d99693 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/controller/MesPlanRecordHistoryController.java @@ -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 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 list = iMesPlanRecordHistoryService.queryList(bo); + ExcelUtil.exportExcel(list, "生产计划明细日期记录历史", MesPlanRecordHistoryVo.class, response); + } + + /** + * 获取生产计划明细日期记录历史详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("mts:planRecordHistory:query") + @GetMapping("/{id}") + public R 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 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 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 remove(@NotEmpty(message = "主键不能为空") +// @PathVariable Long[] ids) { +// return toAjax(iMesPlanRecordHistoryService.deleteWithValidByIds(Arrays.asList(ids), true)); +// } +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/MesPlanRecordHistory.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/MesPlanRecordHistory.java new file mode 100644 index 0000000..ff9f50b --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/MesPlanRecordHistory.java @@ -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; + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/bo/MesPlanRecordHistoryBo.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/bo/MesPlanRecordHistoryBo.java new file mode 100644 index 0000000..c744c51 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/bo/MesPlanRecordHistoryBo.java @@ -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; + + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordHistoryVo.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordHistoryVo.java new file mode 100644 index 0000000..53dd6c7 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordHistoryVo.java @@ -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; + + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordVo.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordVo.java index 4772acc..e8c404b 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordVo.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/domain/vo/MesPlanRecordVo.java @@ -53,5 +53,7 @@ public class MesPlanRecordVo implements Serializable { private String ganttColor; + private Date createTime; + } diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/mapper/MesPlanRecordHistoryMapper.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/mapper/MesPlanRecordHistoryMapper.java new file mode 100644 index 0000000..6ac2a55 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/mapper/MesPlanRecordHistoryMapper.java @@ -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 { + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/IMesPlanRecordHistoryService.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/IMesPlanRecordHistoryService.java new file mode 100644 index 0000000..0b36057 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/IMesPlanRecordHistoryService.java @@ -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 queryPageList(MesPlanRecordHistoryBo bo, PageQuery pageQuery); + + /** + * 查询生产计划明细日期记录历史列表 + */ + List queryList(MesPlanRecordHistoryBo bo); + + /** + * 新增生产计划明细日期记录历史 + */ + Boolean insertByBo(MesPlanRecordHistoryBo bo); + + /** + * 修改生产计划明细日期记录历史 + */ +// Boolean updateByBo(MesPlanRecordHistoryBo bo); + + /** + * 校验并批量删除生产计划明细日期记录历史信息 + */ +// Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanDetailServiceImpl.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanDetailServiceImpl.java index be90a63..8566573 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanDetailServiceImpl.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanDetailServiceImpl.java @@ -50,17 +50,23 @@ public class MesPlanDetailServiceImpl implements IMesPlanDetailService { @Override public List queryList(MesPlanDetailBo bo) { bo.setParentId(0L); - LambdaQueryWrapper lqw = buildQueryWrapper(bo); - List list = baseMapper.selectVoList(lqw); - LinkedList res = new LinkedList<>(); - for (int i = 0; i < list.size(); i++) { - MesPlanDetailVo vo = list.get(i); - res.add(vo); + LambdaQueryWrapper parentQuery = buildQueryWrapper(bo); + List parentList = baseMapper.selectVoList(parentQuery); + //LambdaQueryWrapper childrenQuery = Wrappers.lambdaQuery(MesPlanDetail.class).ne(TreeEntity::getParentId, 0).orderByAsc(MesPlanDetail::getId); + //List childrenList = baseMapper.selectVoList(childrenQuery); + + //Map> childrenCollect = childrenList.stream().collect(Collectors.groupingBy(MesPlanDetailVo::getParentId, Collectors.toList())); + LinkedList res = new LinkedList<>(); + for (int i = 0; i < parentList.size(); i++) { + MesPlanDetailVo vo = parentList.get(i); + res.add(vo); LambdaQueryWrapper voLqw = Wrappers.lambdaQuery(MesPlanDetail.class).eq(TreeEntity::getParentId, vo.getId()).orderByAsc(MesPlanDetail::getId); List children = baseMapper.selectVoList(voLqw); + //List children = childrenCollect.get(vo.getId()); if (CollUtil.isNotEmpty(children)) { res.addAll(i + 1, children); + } } int size = res.size(); diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordHistoryServiceImpl.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordHistoryServiceImpl.java new file mode 100644 index 0000000..8d5c718 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordHistoryServiceImpl.java @@ -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 queryPageList(MesPlanRecordHistoryBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询生产计划明细日期记录历史列表 + */ + @Override + public List queryList(MesPlanRecordHistoryBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(MesPlanRecordHistoryBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper 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 ids, Boolean isValid) { +// if(isValid){ +// //TODO 做一些业务上的校验,判断是否需要校验 +// } +// return baseMapper.deleteBatchIds(ids) > 0; +// } +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordServiceImpl.java b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordServiceImpl.java index 04ed0ea..904c5d5 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordServiceImpl.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/mts/service/impl/MesPlanRecordServiceImpl.java @@ -8,8 +8,10 @@ import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.mts.domain.MesPlanRecord; 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.mapper.MesPlanRecordMapper; +import com.ruoyi.mts.service.IMesPlanRecordHistoryService; import com.ruoyi.mts.service.IMesPlanRecordService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -30,6 +32,8 @@ public class MesPlanRecordServiceImpl implements IMesPlanRecordService { private final MesPlanRecordMapper baseMapper; + private final IMesPlanRecordHistoryService historyService; + /** * 查询生产计划明细日期记录 */ @@ -97,6 +101,14 @@ public class MesPlanRecordServiceImpl implements IMesPlanRecordService { public Boolean updateByBo(MesPlanRecordBo bo) { MesPlanRecord update = BeanUtil.toBean(bo, MesPlanRecord.class); 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; } diff --git a/ruoyi-demo/src/main/resources/mapper/mts/MesPlanRecordHistoryMapper.xml b/ruoyi-demo/src/main/resources/mapper/mts/MesPlanRecordHistoryMapper.xml new file mode 100644 index 0000000..ab9d42e --- /dev/null +++ b/ruoyi-demo/src/main/resources/mapper/mts/MesPlanRecordHistoryMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +