update add车间信息
parent
ad00cbf62b
commit
90e406ffa1
@ -0,0 +1,114 @@
|
||||
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.ProdBaseWorkshopInfoVo;
|
||||
import org.dromara.mes.domain.bo.ProdBaseWorkshopInfoBo;
|
||||
import org.dromara.mes.service.IProdBaseWorkshopInfoService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 车间信息
|
||||
* 前端访问路由地址为:/mes/baseWorkshopInfo
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/baseWorkshopInfo")
|
||||
public class ProdBaseWorkshopInfoController extends BaseController {
|
||||
|
||||
private final IProdBaseWorkshopInfoService prodBaseWorkshopInfoService;
|
||||
|
||||
/**
|
||||
* 查询车间信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ProdBaseWorkshopInfoVo> list(ProdBaseWorkshopInfoBo bo, PageQuery pageQuery) {
|
||||
return prodBaseWorkshopInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车间信息下拉框列表
|
||||
*/
|
||||
@GetMapping("/getWorkshopList")
|
||||
public List<ProdBaseWorkshopInfoVo> getFactoryList(ProdBaseWorkshopInfoBo bo) {
|
||||
return prodBaseWorkshopInfoService.queryList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出车间信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:export")
|
||||
@Log(title = "车间信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ProdBaseWorkshopInfoBo bo, HttpServletResponse response) {
|
||||
List<ProdBaseWorkshopInfoVo> list = prodBaseWorkshopInfoService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "车间信息", ProdBaseWorkshopInfoVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车间信息详细信息
|
||||
*
|
||||
* @param workshopId 主键
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:query")
|
||||
@GetMapping("/{workshopId}")
|
||||
public R<ProdBaseWorkshopInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long workshopId) {
|
||||
return R.ok(prodBaseWorkshopInfoService.queryById(workshopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车间信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:add")
|
||||
@Log(title = "车间信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProdBaseWorkshopInfoBo bo) {
|
||||
return toAjax(prodBaseWorkshopInfoService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车间信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:edit")
|
||||
@Log(title = "车间信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ProdBaseWorkshopInfoBo bo) {
|
||||
return toAjax(prodBaseWorkshopInfoService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车间信息
|
||||
*
|
||||
* @param workshopIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("mes:baseWorkshopInfo:remove")
|
||||
@Log(title = "车间信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{workshopIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] workshopIds) {
|
||||
return toAjax(prodBaseWorkshopInfoService.deleteWithValidByIds(List.of(workshopIds), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.dromara.mes.domain;
|
||||
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 车间信息对象 prod_base_workshop_info
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("prod_base_workshop_info")
|
||||
public class ProdBaseWorkshopInfo extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 车间ID
|
||||
*/
|
||||
@TableId(value = "workshop_id", type = IdType.AUTO)
|
||||
private Long workshopId;
|
||||
|
||||
/**
|
||||
* 车间编号
|
||||
*/
|
||||
private String workshopCode;
|
||||
|
||||
/**
|
||||
* 车间名称
|
||||
*/
|
||||
private String workshopName;
|
||||
|
||||
/**
|
||||
* 所属工厂
|
||||
*/
|
||||
private Long factoryId;
|
||||
|
||||
/**
|
||||
* 激活标识(1是 0否)
|
||||
*/
|
||||
private String activeFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String factoryName;//字段映射
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.dromara.mes.domain.bo;
|
||||
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 车间信息业务对象 prod_base_workshop_info
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ProdBaseWorkshopInfo.class, reverseConvertGenerate = false)
|
||||
public class ProdBaseWorkshopInfoBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 车间ID
|
||||
*/
|
||||
private Long workshopId;
|
||||
|
||||
/**
|
||||
* 车间编号
|
||||
*/
|
||||
@NotBlank(message = "车间编号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String workshopCode;
|
||||
|
||||
/**
|
||||
* 车间名称
|
||||
*/
|
||||
@NotBlank(message = "车间名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String workshopName;
|
||||
|
||||
/**
|
||||
* 所属工厂
|
||||
*/
|
||||
@NotNull(message = "所属工厂不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long factoryId;
|
||||
|
||||
/**
|
||||
* 激活标识(1是 0否)
|
||||
*/
|
||||
@NotBlank(message = "激活标识", groups = {AddGroup.class, EditGroup.class})
|
||||
private String activeFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package org.dromara.mes.domain.vo;
|
||||
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 车间信息视图对象 prod_base_workshop_info
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = ProdBaseWorkshopInfo.class)
|
||||
public class ProdBaseWorkshopInfoVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 车间ID
|
||||
*/
|
||||
@ExcelProperty(value = "车间ID")
|
||||
private Long workshopId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
@ExcelProperty(value = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 车间编号
|
||||
*/
|
||||
@ExcelProperty(value = "车间编号")
|
||||
private String workshopCode;
|
||||
|
||||
/**
|
||||
* 车间名称
|
||||
*/
|
||||
@ExcelProperty(value = "车间名称")
|
||||
private String workshopName;
|
||||
|
||||
/**
|
||||
* 所属工厂ID
|
||||
*/
|
||||
@ExcelProperty(value = "所属工厂ID")
|
||||
private Long factoryId;
|
||||
|
||||
/**
|
||||
* 激活标识(1是 0否)
|
||||
*/
|
||||
@ExcelProperty(value = "激活标识")
|
||||
private String activeFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
@ExcelProperty(value = "创建部门")
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ExcelProperty(value = "创建人")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ExcelProperty(value = "更新人")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 所属工厂名称
|
||||
*/
|
||||
@ExcelProperty(value = "所属工厂名称")
|
||||
private String factoryName;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.dromara.mes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseWorkshopInfoVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.sql.Wrapper;
|
||||
|
||||
/**
|
||||
* 车间信息Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
public interface ProdBaseWorkshopInfoMapper extends BaseMapperPlus<ProdBaseWorkshopInfo, ProdBaseWorkshopInfoVo> {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package org.dromara.mes.service;
|
||||
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseWorkshopInfoVo;
|
||||
import org.dromara.mes.domain.bo.ProdBaseWorkshopInfoBo;
|
||||
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-02
|
||||
*/
|
||||
public interface IProdBaseWorkshopInfoService {
|
||||
|
||||
/**
|
||||
* 查询车间信息
|
||||
*
|
||||
* @param workshopId 主键
|
||||
* @return 车间信息
|
||||
*/
|
||||
ProdBaseWorkshopInfoVo queryById(Long workshopId);
|
||||
|
||||
/**
|
||||
* 分页查询车间信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 车间信息分页列表
|
||||
*/
|
||||
TableDataInfo<ProdBaseWorkshopInfoVo> queryPageList(ProdBaseWorkshopInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的车间信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 车间信息列表
|
||||
*/
|
||||
List<ProdBaseWorkshopInfoVo> queryList(ProdBaseWorkshopInfoBo bo);
|
||||
|
||||
/**
|
||||
* 新增车间信息
|
||||
*
|
||||
* @param bo 车间信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(ProdBaseWorkshopInfoBo bo);
|
||||
|
||||
/**
|
||||
* 修改车间信息
|
||||
*
|
||||
* @param bo 车间信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(ProdBaseWorkshopInfoBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除车间信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package org.dromara.mes.service.impl;
|
||||
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.dromara.mes.domain.ProdBaseFactoryInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.mes.domain.bo.ProdBaseWorkshopInfoBo;
|
||||
import org.dromara.mes.domain.vo.ProdBaseWorkshopInfoVo;
|
||||
import org.dromara.mes.domain.ProdBaseWorkshopInfo;
|
||||
import org.dromara.mes.mapper.ProdBaseWorkshopInfoMapper;
|
||||
import org.dromara.mes.service.IProdBaseWorkshopInfoService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 车间信息Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ProdBaseWorkshopInfoServiceImpl implements IProdBaseWorkshopInfoService {
|
||||
|
||||
private final ProdBaseWorkshopInfoMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询车间信息
|
||||
*
|
||||
* @param workshopId 主键
|
||||
* @return 车间信息
|
||||
*/
|
||||
@Override
|
||||
public ProdBaseWorkshopInfoVo queryById(Long workshopId) {
|
||||
return baseMapper.selectVoById(workshopId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询车间信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 车间信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ProdBaseWorkshopInfoVo> queryPageList(ProdBaseWorkshopInfoBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<ProdBaseWorkshopInfo> lqw = buildQueryWrapper(bo);
|
||||
Page<ProdBaseWorkshopInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的车间信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 车间信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ProdBaseWorkshopInfoVo> queryList(ProdBaseWorkshopInfoBo bo) {
|
||||
MPJLambdaWrapper<ProdBaseWorkshopInfo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<ProdBaseWorkshopInfo> buildQueryWrapper(ProdBaseWorkshopInfoBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<ProdBaseWorkshopInfo> lqw = JoinWrappers.lambda(ProdBaseWorkshopInfo.class)
|
||||
.selectAll(ProdBaseWorkshopInfo.class)
|
||||
.select(ProdBaseFactoryInfo::getFactoryName)
|
||||
.leftJoin(ProdBaseFactoryInfo.class, ProdBaseFactoryInfo::getFactoryId, ProdBaseWorkshopInfo::getFactoryId)
|
||||
.eq(StringUtils.isNotBlank(bo.getWorkshopCode()), ProdBaseWorkshopInfo::getWorkshopCode, bo.getWorkshopCode())
|
||||
.like(StringUtils.isNotBlank(bo.getWorkshopName()), ProdBaseWorkshopInfo::getWorkshopName, bo.getWorkshopName())
|
||||
.eq(bo.getFactoryId() != null, ProdBaseWorkshopInfo::getFactoryId, bo.getFactoryId())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdBaseWorkshopInfo::getActiveFlag, bo.getActiveFlag())
|
||||
.orderByDesc(ProdBaseWorkshopInfo::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车间信息
|
||||
*
|
||||
* @param bo 车间信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ProdBaseWorkshopInfoBo bo) {
|
||||
ProdBaseWorkshopInfo add = MapstructUtils.convert(bo, ProdBaseWorkshopInfo.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setWorkshopId(add.getWorkshopId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车间信息
|
||||
*
|
||||
* @param bo 车间信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ProdBaseWorkshopInfoBo bo) {
|
||||
ProdBaseWorkshopInfo update = MapstructUtils.convert(bo, ProdBaseWorkshopInfo.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ProdBaseWorkshopInfo 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.ProdBaseWorkshopInfoMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue