diff --git a/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java b/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java index dcdb4454..7449d06f 100644 --- a/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java +++ b/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java @@ -35,6 +35,7 @@ public interface ErrorCodeConstants { /*********库存管理************/ ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_003_001, "仓库不存在"); ErrorCode RG_NOT_EXISTS = new ErrorCode(1_003_002, "库区不存在"); + ErrorCode PN_NOT_EXISTS = new ErrorCode(1_003_003, "库位不存在"); diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/PnController.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/PnController.java new file mode 100644 index 00000000..1992bad7 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/PnController.java @@ -0,0 +1,95 @@ +package com.chanko.yunxi.mes.module.heli.controller.admin.pn; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.common.pojo.CommonResult; +import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; +import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success; + +import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils; + +import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog; +import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*; + +import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO; +import com.chanko.yunxi.mes.module.heli.service.pn.PnService; + +@Tag(name = "管理后台 - 库位") +@RestController +@RequestMapping("/heli/pn") +@Validated +public class PnController { + + @Resource + private PnService pnService; + + @PostMapping("/create") + @Operation(summary = "创建库位") + @PreAuthorize("@ss.hasPermission('heli:pn:create')") + public CommonResult createPn(@Valid @RequestBody PnSaveReqVO createReqVO) { + return success(pnService.createPn(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新库位") + @PreAuthorize("@ss.hasPermission('heli:pn:update')") + public CommonResult updatePn(@Valid @RequestBody PnSaveReqVO updateReqVO) { + pnService.updatePn(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除库位") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('heli:pn:delete')") + public CommonResult deletePn(@RequestParam("id") Long id) { + pnService.deletePn(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得库位") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('heli:pn:query')") + public CommonResult getPn(@RequestParam("id") Long id) { + PnDO pn = pnService.getPn(id); + return success(BeanUtils.toBean(pn, PnRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得库位分页") + @PreAuthorize("@ss.hasPermission('heli:pn:query')") + public CommonResult> getPnPage(@Valid PnPageReqVO pageReqVO) { + PageResult pageResult = pnService.getPnPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, PnRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出库位 Excel") + @PreAuthorize("@ss.hasPermission('heli:pn:export')") + @OperateLog(type = EXPORT) + public void exportPnExcel(@Valid PnPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = pnService.getPnPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "库位.xls", "数据", PnRespVO.class, + BeanUtils.toBean(list, PnRespVO.class)); + } + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnPageReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnPageReqVO.java new file mode 100644 index 00000000..96f59418 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnPageReqVO.java @@ -0,0 +1,50 @@ +package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.chanko.yunxi.mes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 库位分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PnPageReqVO extends PageParam { + + @Schema(description = "库位编号,唯一") + private String pnNo; + + @Schema(description = "库位名称,唯一", example = "王五") + private String pnName; + + @Schema(description = "库区 Id,对应 wms_rg 表中的Id", example = "8575") + private Long rgId; + + @Schema(description = "描述信息") + private String descr; + + @Schema(description = "状态,1 表示正常,2 表示禁用", example = "2") + private Integer pnStatus; + + @Schema(description = "记录的创建人,对应员工表中的 Id") + private String creator; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "记录的修改人,对应员工表中的 Id") + private String updater; + + @Schema(description = "更新时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] updateTime; + + @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", example = "12289") + private Long whId; + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnRespVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnRespVO.java new file mode 100644 index 00000000..210d024a --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnRespVO.java @@ -0,0 +1,52 @@ +package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import com.chanko.yunxi.mes.framework.excel.core.annotations.DictFormat; +import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 库位 Response VO") +@Data +@ExcelIgnoreUnannotated +public class PnRespVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15359") + @ExcelProperty("主键id") + private Long id; + + @Schema(description = "库位编号,唯一") + @ExcelProperty("库位编号,唯一") + private String pnNo; + + @Schema(description = "库位名称,唯一", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @ExcelProperty("库位名称,唯一") + private String pnName; + + @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8575") + @ExcelProperty(value = "库区 Id,对应 wms_rg 表中的Id", converter = DictConvert.class) + @DictFormat("heli_common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Long rgId; + + @Schema(description = "描述信息") + @ExcelProperty("描述信息") + private String descr; + + @Schema(description = "状态,1 表示正常,2 表示禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty("状态,1 表示正常,2 表示禁用") + private Integer pnStatus; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12289") + @ExcelProperty(value = "仓库 Id,对应 wms_wh 表中的Id", converter = DictConvert.class) + @DictFormat("heli_common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Long whId; + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnSaveReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnSaveReqVO.java new file mode 100644 index 00000000..18656c5e --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/pn/vo/PnSaveReqVO.java @@ -0,0 +1,38 @@ +package com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.util.*; + +@Schema(description = "管理后台 - 库位新增/修改 Request VO") +@Data +public class PnSaveReqVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15359") + private Long id; + + @Schema(description = "库位编号,唯一") + private String pnNo; + + @Schema(description = "库位名称,唯一", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @NotEmpty(message = "库位名称,唯一不能为空") + private String pnName; + + @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8575") + @NotNull(message = "库区 Id,对应 wms_rg 表中的Id不能为空") + private Long rgId; + + @Schema(description = "描述信息") + private String descr; + + @Schema(description = "状态,1 表示正常,2 表示禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @NotNull(message = "状态,1 表示正常,2 表示禁用不能为空") + private Integer pnStatus; + + @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12289") + @NotNull(message = "仓库 Id,对应 wms_wh 表中的Id不能为空") + private Long whId; + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/pn/PnDO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/pn/PnDO.java new file mode 100644 index 00000000..d403c9ea --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/pn/PnDO.java @@ -0,0 +1,59 @@ +package com.chanko.yunxi.mes.module.heli.dal.dataobject.pn; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO; + +/** + * 库位 DO + * + * @author 管理员 + */ +@TableName("wms_pn") +@KeySequence("wms_pn_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PnDO extends BaseDO { + + /** + * 主键id + */ + @TableId + private Long id; + /** + * 库位编号,唯一 + */ + private String pnNo; + /** + * 库位名称,唯一 + */ + private String pnName; + /** + * 库区 Id,对应 wms_rg 表中的Id + * + * 枚举 {@link TODO heli_common_status 对应的类} + */ + private Long rgId; + /** + * 描述信息 + */ + private String descr; + /** + * 状态,1 表示正常,2 表示禁用 + */ + private Integer pnStatus; + /** + * 仓库 Id,对应 wms_wh 表中的Id + * + * 枚举 {@link TODO heli_common_status 对应的类} + */ + private Long whId; + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/pn/PnMapper.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/pn/PnMapper.java new file mode 100644 index 00000000..569e9830 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/pn/PnMapper.java @@ -0,0 +1,35 @@ +package com.chanko.yunxi.mes.module.heli.dal.mysql.pn; + +import java.util.*; + +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO; +import org.apache.ibatis.annotations.Mapper; +import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*; + +/** + * 库位 Mapper + * + * @author 管理员 + */ +@Mapper +public interface PnMapper extends BaseMapperX { + + default PageResult selectPage(PnPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(PnDO::getPnNo, reqVO.getPnNo()) + .likeIfPresent(PnDO::getPnName, reqVO.getPnName()) + .eqIfPresent(PnDO::getRgId, reqVO.getRgId()) + .eqIfPresent(PnDO::getDescr, reqVO.getDescr()) + .eqIfPresent(PnDO::getPnStatus, reqVO.getPnStatus()) + .eqIfPresent(PnDO::getCreator, reqVO.getCreator()) + .betweenIfPresent(PnDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(PnDO::getUpdater, reqVO.getUpdater()) + .betweenIfPresent(PnDO::getUpdateTime, reqVO.getUpdateTime()) + .eqIfPresent(PnDO::getWhId, reqVO.getWhId()) + .orderByDesc(PnDO::getId)); + } + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnService.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnService.java new file mode 100644 index 00000000..7a30460e --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnService.java @@ -0,0 +1,55 @@ +package com.chanko.yunxi.mes.module.heli.service.pn; + +import java.util.*; +import javax.validation.*; +import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO; +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; + +/** + * 库位 Service 接口 + * + * @author 管理员 + */ +public interface PnService { + + /** + * 创建库位 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPn(@Valid PnSaveReqVO createReqVO); + + /** + * 更新库位 + * + * @param updateReqVO 更新信息 + */ + void updatePn(@Valid PnSaveReqVO updateReqVO); + + /** + * 删除库位 + * + * @param id 编号 + */ + void deletePn(Long id); + + /** + * 获得库位 + * + * @param id 编号 + * @return 库位 + */ + PnDO getPn(Long id); + + /** + * 获得库位分页 + * + * @param pageReqVO 分页查询 + * @return 库位分页 + */ + PageResult getPnPage(PnPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnServiceImpl.java new file mode 100644 index 00000000..ddac994c --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/pn/PnServiceImpl.java @@ -0,0 +1,74 @@ +package com.chanko.yunxi.mes.module.heli.service.pn; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import com.chanko.yunxi.mes.module.heli.controller.admin.pn.vo.*; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.pn.PnDO; +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; +import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; + +import com.chanko.yunxi.mes.module.heli.dal.mysql.pn.PnMapper; + +import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*; + +/** + * 库位 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class PnServiceImpl implements PnService { + + @Resource + private PnMapper pnMapper; + + @Override + public Long createPn(PnSaveReqVO createReqVO) { + // 插入 + PnDO pn = BeanUtils.toBean(createReqVO, PnDO.class); + pnMapper.insert(pn); + // 返回 + return pn.getId(); + } + + @Override + public void updatePn(PnSaveReqVO updateReqVO) { + // 校验存在 + validatePnExists(updateReqVO.getId()); + // 更新 + PnDO updateObj = BeanUtils.toBean(updateReqVO, PnDO.class); + pnMapper.updateById(updateObj); + } + + @Override + public void deletePn(Long id) { + // 校验存在 + validatePnExists(id); + // 删除 + pnMapper.deleteById(id); + } + + private void validatePnExists(Long id) { + if (pnMapper.selectById(id) == null) { + throw exception(PN_NOT_EXISTS); + } + } + + @Override + public PnDO getPn(Long id) { + return pnMapper.selectById(id); + } + + @Override + public PageResult getPnPage(PnPageReqVO pageReqVO) { + return pnMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/pn/PnMapper.xml b/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/pn/PnMapper.xml new file mode 100644 index 00000000..756d99d0 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/pn/PnMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/mes-ui/mes-ui-admin-vue3/src/api/heli/pn/index.ts b/mes-ui/mes-ui-admin-vue3/src/api/heli/pn/index.ts new file mode 100644 index 00000000..d20819e6 --- /dev/null +++ b/mes-ui/mes-ui-admin-vue3/src/api/heli/pn/index.ts @@ -0,0 +1,41 @@ +import request from '@/config/axios' + +export interface PnVO { + id: number + pnNo: string + pnName: string + rgId: number + descr: string + pnStatus: number + whId: number +} + +// 查询库位分页 +export const getPnPage = async (params) => { + return await request.get({ url: `/heli/pn/page`, params }) +} + +// 查询库位详情 +export const getPn = async (id: number) => { + return await request.get({ url: `/heli/pn/get?id=` + id }) +} + +// 新增库位 +export const createPn = async (data: PnVO) => { + return await request.post({ url: `/heli/pn/create`, data }) +} + +// 修改库位 +export const updatePn = async (data: PnVO) => { + return await request.put({ url: `/heli/pn/update`, data }) +} + +// 删除库位 +export const deletePn = async (id: number) => { + return await request.delete({ url: `/heli/pn/delete?id=` + id }) +} + +// 导出库位 Excel +export const exportPn = async (params) => { + return await request.download({ url: `/heli/pn/export-excel`, params }) +} \ No newline at end of file diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/PnForm.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/PnForm.vue new file mode 100644 index 00000000..e0745bf2 --- /dev/null +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/PnForm.vue @@ -0,0 +1,134 @@ + + \ No newline at end of file diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/index.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/index.vue new file mode 100644 index 00000000..bb5fd212 --- /dev/null +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/pn/index.vue @@ -0,0 +1,295 @@ + + + \ No newline at end of file