This commit is contained in:
闫阳 2022-08-09 15:19:26 +08:00
parent 16a52e69c8
commit 63f3f98ca8
9 changed files with 377 additions and 1 deletions

View File

@ -27,7 +27,7 @@ public class CodeGenerator {
@Test
public void test(){
mybatisPlusGenerator(new String[]{"product_features"});
mybatisPlusGenerator(new String[]{"working_procedure"});
}
public static void mybatisPlusGenerator(String[] include){

View File

@ -0,0 +1,116 @@
package com.cnbm.generator.code.controller;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData;
import com.cnbm.common.utils.ExcelUtils;
import com.cnbm.common.utils.Result;
import com.cnbm.common.validator.AssertUtils;
import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.generator.code.dto.WorkingProcedureDTO;
import com.cnbm.generator.code.excel.WorkingProcedureExcel;
import com.cnbm.generator.code.service.IWorkingProcedureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 工序 前端控制器
*
* @author why
* @since 2022-08-03
*/
@RestController
@RequestMapping("/code/workingProcedure")
@Api(tags="工序 表")
public class WorkingProcedureController {
@Autowired
private IWorkingProcedureService workingProcedureService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
})
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:page')")
public Result<PageData<WorkingProcedureDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<WorkingProcedureDTO> page = workingProcedureService.page(params);
return new Result<PageData<WorkingProcedureDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:info')")
public Result<WorkingProcedureDTO> get(@PathVariable("id") Long id){
WorkingProcedureDTO data = workingProcedureService.get(id);
return new Result<WorkingProcedureDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:save')")
public Result save(@RequestBody WorkingProcedureDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
workingProcedureService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:update')")
public Result update(@RequestBody WorkingProcedureDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
workingProcedureService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:delete')")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
workingProcedureService.delete(ids);
return new Result();
}
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
@PreAuthorize("@ex.hasAuthority('code:workingProcedure:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<WorkingProcedureDTO> list = workingProcedureService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, WorkingProcedureExcel.class);
}
}

View File

@ -0,0 +1,71 @@
package com.cnbm.generator.code.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.math.BigDecimal;
/**
* 工序
*
* @author why
* @since 2022-08-03
*/
@Data
@ApiModel(value = "工序 表DTO对象")
public class WorkingProcedureDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
private Long id;
@ApiModelProperty(value = "工序 名")
private String name;
@ApiModelProperty(value = "工序 编码")
private String code;
@ApiModelProperty(value = "工序类型 id,关联working_procedure_type表")
private Long workingProcedureTypeId;
@ApiModelProperty(value = "机台(也就是设备),这个工序对应的设备,可能有一个或者多个,如果多个用逗号隔开,\"id1,id2,......\"")
private String machineId;
@ApiModelProperty(value = "1 可用0 不可用")
private Integer status;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用")
private Integer valid;
@ApiModelProperty(value = "")
private Long creatorId;
@ApiModelProperty(value = "创建人姓名")
private String creatorName;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "")
private Long updaterId;
@ApiModelProperty(value = "更新人姓名")
private String updaterName;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
@ApiModelProperty(value = "版本号")
private Integer version;
}

View File

@ -0,0 +1,69 @@
package com.cnbm.generator.code.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 工序
* </p>
*
* @author why
* @since 2022-08-03
*/
@Data
@TableName("working_procedure")
@ApiModel(value = "WorkingProcedure对象", description = "工序 表")
public class WorkingProcedure implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("工序 名")
private String name;
@ApiModelProperty("工序 编码")
private String code;
@ApiModelProperty("工序类型 id,关联working_procedure_type表")
private Long workingProcedureTypeId;
@ApiModelProperty("机台(也就是设备),这个工序对应的设备,可能有一个或者多个,如果多个用逗号隔开,\"id1,id2,......\"")
private String machineId;
@ApiModelProperty("1 可用0 不可用")
private Integer status;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("删除标志,是否有效:1 可用 0不可用")
private Integer valid;
private Long creatorId;
@ApiModelProperty("创建人姓名")
private String creatorName;
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
private Long updaterId;
@ApiModelProperty("更新人姓名")
private String updaterName;
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;
@ApiModelProperty("版本号")
private Integer version;
}

View File

@ -0,0 +1,50 @@
package com.cnbm.generator.code.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.Date;
/**
* 工序
*
* @author why
* @since 2022-08-03
*/
@Data
public class WorkingProcedureExcel {
@Excel(name = "ID")
private Long id;
@Excel(name = "工序 名")
private String name;
@Excel(name = "工序 编码")
private String code;
@Excel(name = "工序类型 id,关联working_procedure_type表")
private Long workingProcedureTypeId;
@Excel(name = "机台(也就是设备),这个工序对应的设备,可能有一个或者多个,如果多个用逗号隔开,\"id1,id2,......\"")
private String machineId;
@Excel(name = "1 可用0 不可用")
private Integer status;
@Excel(name = "备注")
private String remark;
@Excel(name = "删除标志,是否有效:1 可用 0不可用")
private Integer valid;
@Excel(name = "")
private Long creatorId;
@Excel(name = "创建人姓名")
private String creatorName;
@Excel(name = "创建时间")
private LocalDateTime createTime;
@Excel(name = "")
private Long updaterId;
@Excel(name = "更新人姓名")
private String updaterName;
@Excel(name = "更新时间")
private LocalDateTime updateTime;
@Excel(name = "版本号")
private Integer version;
}

View File

@ -0,0 +1,16 @@
package com.cnbm.generator.code.mapper;
import com.cnbm.common.dao.BaseDao;
import com.cnbm.generator.code.entity.WorkingProcedure;
import org.apache.ibatis.annotations.Mapper;
/**
* 工序
*
* @author why
* @since 2022-08-03
*/
@Mapper
public interface WorkingProcedureMapper extends BaseDao<WorkingProcedure> {
}

View File

@ -0,0 +1,5 @@
<?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.cnbm.generator.code.mapper.WorkingProcedureMapper">
</mapper>

View File

@ -0,0 +1,15 @@
package com.cnbm.generator.code.service;
import com.cnbm.common.service.CrudService;
import com.cnbm.generator.code.dto.WorkingProcedureDTO;
import com.cnbm.generator.code.entity.WorkingProcedure;
/**
* 工序
*
* @author why
* @since 2022-08-03
*/
public interface IWorkingProcedureService extends CrudService<WorkingProcedure, WorkingProcedureDTO> {
}

View File

@ -0,0 +1,34 @@
package com.cnbm.generator.code.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.generator.code.dto.WorkingProcedureDTO;
import com.cnbm.generator.code.mapper.WorkingProcedureMapper;
import com.cnbm.generator.code.entity.WorkingProcedure;
import com.cnbm.generator.code.service.IWorkingProcedureService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 工序
*
* @author why
* @since 2022-08-03
*/
@Service
public class WorkingProcedureServiceImpl extends CrudServiceImpl<WorkingProcedureMapper, WorkingProcedure, WorkingProcedureDTO> implements IWorkingProcedureService {
@Override
public QueryWrapper<WorkingProcedure> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<WorkingProcedure> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper;
}
}