1.添加建垛规则相关实体类和接口

master
x_z 3 years ago
parent 131438ed45
commit b0fee6307d

@ -30,3 +30,22 @@ CREATE TABLE `stack_order` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
DROP TABLE IF EXISTS `stock_rules`;
CREATE TABLE `stock_rules` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '建垛规则名称',
`customerId` bigint NULL DEFAULT NULL COMMENT '客户ID',
`prefix` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '前缀',
`startNum` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '起始数',
`step` int NULL DEFAULT NULL COMMENT '步进数',
`serialNum` int NULL DEFAULT NULL COMMENT '顺序号',
`status` tinyint(1) NULL DEFAULT NULL COMMENT '启用状态0禁用1启用',
`createTime` datetime NULL DEFAULT NULL COMMENT '创建时间',
`updateTime` datetime NULL DEFAULT NULL COMMENT '更新时间',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '建垛规则表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

@ -0,0 +1,90 @@
package com.glxp.udi.admin.controller.basic;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.glxp.udi.admin.common.enums.ResultEnum;
import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.common.util.ResultVOUtils;
import com.glxp.udi.admin.entity.basic.StockRulesEntity;
import com.glxp.udi.admin.req.basic.FilterStockRulesRequest;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.service.basic.StockRulesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
*
*/
@Slf4j
@RestController
public class StockRulesController {
@Resource
private StockRulesService stockRulesService;
/**
*
*
* @param filterStockRulesRequest
* @return
*/
@GetMapping("/udims/stockRules/filter")
public BaseResponse filterStockRules(FilterStockRulesRequest filterStockRulesRequest) {
IPage<StockRulesEntity> page = stockRulesService.filter(filterStockRulesRequest);
PageSimpleResponse<StockRulesEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setList(page.getRecords());
pageSimpleResponse.setTotal(page.getTotal());
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @param stockRulesEntity
* @return
*/
@PostMapping("/udims/stockRules/add")
public BaseResponse addStockRules(@RequestBody StockRulesEntity stockRulesEntity) {
stockRulesService.addStockRules(stockRulesEntity);
return ResultVOUtils.success();
}
/**
*
*
* @param stockRulesEntity
* @return
*/
@PostMapping("/udims/stockRules/update")
public BaseResponse updateStockRules(@RequestBody StockRulesEntity stockRulesEntity, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
stockRulesService.updateStockRules(stockRulesEntity);
return ResultVOUtils.success("更新成功");
}
/**
*
*
* @param deleteRequest
* @return
*/
@PostMapping("/udims/stockRules/delete")
public BaseResponse deleteStockRules(@RequestBody DeleteRequest deleteRequest) {
if (null == deleteRequest || StrUtil.isNotBlank(deleteRequest.getId())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
stockRulesService.delete(deleteRequest.getId());
return ResultVOUtils.success("删除成功");
}
}

@ -0,0 +1,27 @@
package com.glxp.udi.admin.req.basic;
import com.glxp.udi.admin.req.ListPageRequest;
import lombok.Data;
/**
*
*/
@Data
public class FilterStockRulesRequest extends ListPageRequest {
/**
*
*/
private String name;
/**
* ID
*/
private String customerId;
/**
* 0 1
*/
private Integer status;
}

@ -0,0 +1,88 @@
package com.glxp.udi.admin.service.basic;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.basic.StockRulesDao;
import com.glxp.udi.admin.entity.basic.StockRulesEntity;
import com.glxp.udi.admin.req.basic.FilterStockRulesRequest;
import com.glxp.udi.admin.service.auth.AuthAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
/**
* Service
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class StockRulesService {
@Resource
private StockRulesDao stockRulesDao;
@Resource
private AuthAdminService authAdminService;
/**
*
*
* @param filterStockRulesRequest
* @return
*/
public IPage<StockRulesEntity> filter(FilterStockRulesRequest filterStockRulesRequest) {
QueryWrapper<StockRulesEntity> wrapper = buildWrapper(filterStockRulesRequest);
IPage<StockRulesEntity> page = new Page<>(filterStockRulesRequest.getPage(), filterStockRulesRequest.getLimit());
return stockRulesDao.selectPage(page, wrapper);
}
/**
*
*
* @param filterStockRulesRequest
* @return
*/
private QueryWrapper<StockRulesEntity> buildWrapper(FilterStockRulesRequest filterStockRulesRequest) {
QueryWrapper<StockRulesEntity> wrapper = new QueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(filterStockRulesRequest.getName()), "name", filterStockRulesRequest.getName())
.eq(null != filterStockRulesRequest.getStatus(), "status", filterStockRulesRequest.getStatus())
.eq(StrUtil.isNotBlank(filterStockRulesRequest.getCustomerId()), "customerId", filterStockRulesRequest.getCustomerId());
return wrapper;
}
/**
*
*
* @param stockRulesEntity
*/
public void addStockRules(StockRulesEntity stockRulesEntity) {
stockRulesEntity.setCreateTime(new Date());
stockRulesEntity.setUpdateTime(new Date());
String customerId = authAdminService.getCurrentUserCustomerId();
stockRulesEntity.setCustomerId(Long.valueOf(customerId));
stockRulesDao.insert(stockRulesEntity);
}
/**
*
*
* @param stockRulesEntity
*/
public void updateStockRules(StockRulesEntity stockRulesEntity) {
stockRulesEntity.setUpdateTime(new Date());
stockRulesDao.updateStockRules(stockRulesEntity);
}
/**
*
*
* @param id
*/
public void delete(String id) {
stockRulesDao.deleteById(id);
}
}
Loading…
Cancel
Save