1.添加建垛规则相关实体类和接口
parent
131438ed45
commit
b0fee6307d
@ -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,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…
Reference in New Issue