update add产线信息
parent
f14dcd15fe
commit
c0003881bb
@ -0,0 +1,116 @@
|
||||
package org.dromara.mes.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.mes.domain.vo.ProdBaseProdLineInfoVo;
|
||||
import org.dromara.mes.domain.bo.ProdBaseProdLineInfoBo;
|
||||
import org.dromara.mes.service.IProdBaseProdLineInfoService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 产线信息
|
||||
* 前端访问路由地址为:/mes/baseProdLineInfo
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-06
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/baseProdLineInfo")
|
||||
public class ProdBaseProdLineInfoController extends BaseController {
|
||||
|
||||
private final IProdBaseProdLineInfoService prodBaseProdLineInfoService;
|
||||
|
||||
/**
|
||||
* 查询产线信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ProdBaseProdLineInfoVo> list(ProdBaseProdLineInfoBo bo, PageQuery pageQuery) {
|
||||
return prodBaseProdLineInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产线信息下拉框列表
|
||||
*/
|
||||
@GetMapping("/getProdLineList")
|
||||
public R<List<ProdBaseProdLineInfoVo>> getFactoryList(ProdBaseProdLineInfoBo bo) {
|
||||
List<ProdBaseProdLineInfoVo> list = prodBaseProdLineInfoService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出产线信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:export")
|
||||
@Log(title = "产线信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ProdBaseProdLineInfoBo bo, HttpServletResponse response) {
|
||||
List<ProdBaseProdLineInfoVo> list = prodBaseProdLineInfoService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "产线信息", ProdBaseProdLineInfoVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取产线信息详细信息
|
||||
*
|
||||
* @param prodLineId 主键
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:query")
|
||||
@GetMapping("/{prodLineId}")
|
||||
public R<ProdBaseProdLineInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long prodLineId) {
|
||||
return R.ok(prodBaseProdLineInfoService.queryById(prodLineId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增产线信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:add")
|
||||
@Log(title = "产线信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProdBaseProdLineInfoBo bo) {
|
||||
return toAjax(prodBaseProdLineInfoService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产线信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:edit")
|
||||
@Log(title = "产线信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ProdBaseProdLineInfoBo bo) {
|
||||
return toAjax(prodBaseProdLineInfoService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产线信息
|
||||
*
|
||||
* @param prodLineIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("mes:baseProdLineInfo:remove")
|
||||
@Log(title = "产线信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{prodLineIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] prodLineIds) {
|
||||
return toAjax(prodBaseProdLineInfoService.deleteWithValidByIds(List.of(prodLineIds), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.mes.mapper;
|
||||
|
||||
import org.dromara.mes.domain.ProdBaseProdLineInfo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseProdLineInfoVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 产线信息Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-06
|
||||
*/
|
||||
public interface ProdBaseProdLineInfoMapper extends BaseMapperPlus<ProdBaseProdLineInfo, ProdBaseProdLineInfoVo> {
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.dromara.mes.service;
|
||||
|
||||
import org.dromara.mes.domain.ProdBaseProdLineInfo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseProdLineInfoVo;
|
||||
import org.dromara.mes.domain.bo.ProdBaseProdLineInfoBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产线信息Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-06
|
||||
*/
|
||||
public interface IProdBaseProdLineInfoService {
|
||||
|
||||
/**
|
||||
* 查询产线信息
|
||||
*
|
||||
* @param prodLineId 主键
|
||||
* @return 产线信息
|
||||
*/
|
||||
ProdBaseProdLineInfoVo queryById(Long prodLineId);
|
||||
|
||||
/**
|
||||
* 分页查询产线信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 产线信息分页列表
|
||||
*/
|
||||
TableDataInfo<ProdBaseProdLineInfoVo> queryPageList(ProdBaseProdLineInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的产线信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 产线信息列表
|
||||
*/
|
||||
List<ProdBaseProdLineInfoVo> queryList(ProdBaseProdLineInfoBo bo);
|
||||
|
||||
/**
|
||||
* 新增产线信息
|
||||
*
|
||||
* @param bo 产线信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(ProdBaseProdLineInfoBo bo);
|
||||
|
||||
/**
|
||||
* 修改产线信息
|
||||
*
|
||||
* @param bo 产线信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(ProdBaseProdLineInfoBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除产线信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package org.dromara.mes.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.mes.domain.bo.ProdBaseProdLineInfoBo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseProdLineInfoVo;
|
||||
import org.dromara.mes.domain.ProdBaseProdLineInfo;
|
||||
import org.dromara.mes.mapper.ProdBaseProdLineInfoMapper;
|
||||
import org.dromara.mes.service.IProdBaseProdLineInfoService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 产线信息Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-06
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ProdBaseProdLineInfoServiceImpl implements IProdBaseProdLineInfoService {
|
||||
|
||||
private final ProdBaseProdLineInfoMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询产线信息
|
||||
*
|
||||
* @param prodLineId 主键
|
||||
* @return 产线信息
|
||||
*/
|
||||
@Override
|
||||
public ProdBaseProdLineInfoVo queryById(Long prodLineId){
|
||||
return baseMapper.selectVoById(prodLineId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询产线信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 产线信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ProdBaseProdLineInfoVo> queryPageList(ProdBaseProdLineInfoBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<ProdBaseProdLineInfo> lqw = buildQueryWrapper(bo);
|
||||
Page<ProdBaseProdLineInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的产线信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 产线信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ProdBaseProdLineInfoVo> queryList(ProdBaseProdLineInfoBo bo) {
|
||||
MPJLambdaWrapper<ProdBaseProdLineInfo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<ProdBaseProdLineInfo> buildQueryWrapper(ProdBaseProdLineInfoBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<ProdBaseProdLineInfo> lqw = JoinWrappers.lambda(ProdBaseProdLineInfo.class)
|
||||
.selectAll(ProdBaseProdLineInfo.class)
|
||||
.select(ProdBaseWorkshopInfo::getWorkshopName)
|
||||
.leftJoin(ProdBaseWorkshopInfo.class, ProdBaseWorkshopInfo::getWorkshopId, ProdBaseProdLineInfo::getWorkshopId)
|
||||
.eq(bo.getProdLineId() != null, ProdBaseProdLineInfo::getProdLineId, bo.getProdLineId())
|
||||
.eq(StringUtils.isNotBlank(bo.getProdLineCode()), ProdBaseProdLineInfo::getProdLineCode, bo.getProdLineCode())
|
||||
.like(StringUtils.isNotBlank(bo.getProdLineName()), ProdBaseProdLineInfo::getProdLineName, bo.getProdLineName())
|
||||
.eq(StringUtils.isNotBlank(bo.getProdLineType()), ProdBaseProdLineInfo::getProdLineType, bo.getProdLineType())
|
||||
.eq(bo.getWorkshopId() != null, ProdBaseProdLineInfo::getWorkshopId, bo.getWorkshopId())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdBaseProdLineInfo::getActiveFlag, bo.getActiveFlag())
|
||||
.orderByAsc(ProdBaseProdLineInfo::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增产线信息
|
||||
*
|
||||
* @param bo 产线信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ProdBaseProdLineInfoBo bo) {
|
||||
ProdBaseProdLineInfo add = MapstructUtils.convert(bo, ProdBaseProdLineInfo.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setProdLineId(add.getProdLineId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产线信息
|
||||
*
|
||||
* @param bo 产线信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ProdBaseProdLineInfoBo bo) {
|
||||
ProdBaseProdLineInfo update = MapstructUtils.convert(bo, ProdBaseProdLineInfo.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ProdBaseProdLineInfo entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除产线信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.mes.mapper.ProdBaseProdLineInfoMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue