update add车间信息

master
yinq 3 months ago
parent ad00cbf62b
commit 90e406ffa1

@ -46,6 +46,15 @@ public class ProdBaseFactoryInfoController extends BaseController {
return prodBaseFactoryInfoService.queryPageList(bo, pageQuery);
}
/**
*
*/
@GetMapping("/getFactoryList")
public R<List<ProdBaseFactoryInfoVo>> getFactoryList(ProdBaseFactoryInfoBo bo) {
List<ProdBaseFactoryInfoVo> list = prodBaseFactoryInfoService.queryList(bo);
return R.ok(list);
}
/**
*
*/

@ -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…
Cancel
Save