parent
9b9ae5657d
commit
9d08576d0a
@ -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<Long> createPn(@Valid @RequestBody PnSaveReqVO createReqVO) {
|
||||
return success(pnService.createPn(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新库位")
|
||||
@PreAuthorize("@ss.hasPermission('heli:pn:update')")
|
||||
public CommonResult<Boolean> 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<Boolean> 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<PnRespVO> 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<PageResult<PnRespVO>> getPnPage(@Valid PnPageReqVO pageReqVO) {
|
||||
PageResult<PnDO> 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<PnDO> list = pnService.getPnPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "库位.xls", "数据", PnRespVO.class,
|
||||
BeanUtils.toBean(list, PnRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -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<PnDO> {
|
||||
|
||||
default PageResult<PnDO> selectPage(PnPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PnDO>()
|
||||
.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));
|
||||
}
|
||||
|
||||
}
|
@ -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<PnDO> getPnPage(PnPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -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<PnDO> getPnPage(PnPageReqVO pageReqVO) {
|
||||
return pnMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -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 })
|
||||
}
|
Loading…
Reference in new issue