分库功能修改,beta版
parent
752dc93d98
commit
001fe3190d
@ -0,0 +1,116 @@
|
||||
package com.glxp.api.admin.controller.inventory;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
||||
import com.glxp.api.admin.entity.inventory.InvWarehouseEntity;
|
||||
import com.glxp.api.admin.req.inout.DeleteRequest;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest;
|
||||
import com.glxp.api.admin.service.auth.CustomerService;
|
||||
import com.glxp.api.admin.service.inventory.InvSubWarehouseService;
|
||||
import com.glxp.api.admin.service.inventory.InvWarehouseService;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
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;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class InvSubWarehouseController {
|
||||
|
||||
@Resource
|
||||
InvSubWarehouseService invSubWarehouseService;
|
||||
@Resource
|
||||
InvWarehouseService invWarehouseService;
|
||||
@Resource
|
||||
CustomerService customerService;
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("spms/sub/inv/warehouse/filter")
|
||||
public BaseResponse filterInvWarehouse(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest) {
|
||||
List<InvSubWarehouseEntity> invSubWarehouseEntities = invSubWarehouseService.filterInvSubWarehouse(filterInvSubWarehouseRequest);
|
||||
return ResultVOUtils.success(invSubWarehouseEntities);
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("spms/sub/inv/warehouse/findByInv")
|
||||
public BaseResponse findByInv(FilterInvWarehouseRequest filterInvWarehouseRequest) {
|
||||
AuthAdmin authAdmin = customerService.getUserBean();
|
||||
filterInvWarehouseRequest.setUserId(authAdmin.getId().intValue());
|
||||
List<InvSubWarehouseEntity> invSubWarehouseEntities = invSubWarehouseService.filterGroupInvSub(filterInvWarehouseRequest);
|
||||
return ResultVOUtils.success(invSubWarehouseEntities);
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/spms/sub/inv/warehouse/save")
|
||||
public BaseResponse save(@RequestBody @Valid InvSubWarehouseEntity invSubWarehouseEntity,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
|
||||
|
||||
FilterInvSubWarehouseRequest filterInvWarehouseRequest = new FilterInvSubWarehouseRequest();
|
||||
filterInvWarehouseRequest.setParentId(invSubWarehouseEntity.getParentId());
|
||||
InvSubWarehouseEntity codeEntity = invSubWarehouseService.selectMaxCode(filterInvWarehouseRequest);
|
||||
InvWarehouseEntity pEntity = invWarehouseService.selectByCode(invSubWarehouseEntity.getParentId());
|
||||
if (codeEntity == null) {
|
||||
int code = Integer.parseInt(pEntity.getCode()) * 1000;
|
||||
invSubWarehouseEntity.setCode(code + "");
|
||||
} else {
|
||||
invSubWarehouseEntity.setCode(Integer.parseInt(codeEntity.getCode()) + 1 + "");
|
||||
}
|
||||
invSubWarehouseEntity.setId(IdUtil.getSnowflake(6, 1).nextId() + "");
|
||||
boolean b = invSubWarehouseService.insertInvSubWarehouse(invSubWarehouseEntity);
|
||||
if (!b) {
|
||||
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||
}
|
||||
return ResultVOUtils.success("添加成功!");
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/spms/sub/inv/warehouse/edit")
|
||||
public BaseResponse edit(@RequestBody @Valid InvSubWarehouseEntity invSubWarehouseEntity,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
if (invSubWarehouseEntity.getId() == null) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
boolean b = invSubWarehouseService.updateInvSubWarehouse(invSubWarehouseEntity);
|
||||
if (!b) {
|
||||
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||
}
|
||||
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/spms/sub/inv/warehouse/delete")
|
||||
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
|
||||
|
||||
if (deleteRequest.getId() == null) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
boolean b = invSubWarehouseService.deleteById(deleteRequest.getId());
|
||||
if (!b) {
|
||||
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||
}
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.glxp.api.admin.dao.inventory;
|
||||
|
||||
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InvSubWarehouseDao {
|
||||
|
||||
List<InvSubWarehouseEntity> filterInvSubWarehouse(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
List<InvSubWarehouseEntity> filterGroupInvSub(FilterInvWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
InvSubWarehouseEntity selectMaxCode(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
boolean insertInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||
|
||||
boolean updateInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||
|
||||
void importInvSubWarehouse(@Param("invWarehouseEntities") List<InvSubWarehouseEntity> invSubWarehouseEntities);
|
||||
|
||||
boolean deleteById(String id);
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.glxp.api.admin.entity.inventory;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class InvSubWarehouseEntity {
|
||||
|
||||
private String id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private String remark;
|
||||
private boolean defaultInv;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.glxp.api.admin.req.inventory;
|
||||
|
||||
import com.glxp.api.admin.req.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FilterInvSubWarehouseRequest extends ListPageRequest {
|
||||
|
||||
private Integer id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private Boolean defaultInv;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.glxp.api.admin.res.inout;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseUserResponse {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 仓位码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 用户名/登录账号
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 是否是仓库主管
|
||||
*/
|
||||
private boolean isDirector;
|
||||
|
||||
private String employeeName;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.glxp.api.admin.service.inventory;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InvSubWarehouseService {
|
||||
|
||||
List<InvSubWarehouseEntity> filterInvSubWarehouse(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
List<InvSubWarehouseEntity> filterGroupInvSub(FilterInvWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
InvSubWarehouseEntity selectMaxCode(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest);
|
||||
|
||||
List<InvSubWarehouseEntity> findByParentId(String code);
|
||||
|
||||
InvSubWarehouseEntity findByInvSubByCode(String code);
|
||||
|
||||
boolean insertInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||
|
||||
boolean updateInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||
|
||||
boolean deleteById(String id);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.glxp.api.admin.service.inventory.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.dao.inventory.InvSubWarehouseDao;
|
||||
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||
import com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest;
|
||||
import com.glxp.api.admin.service.inventory.InvSubWarehouseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class InvSubWarehouseServiceImpl implements InvSubWarehouseService {
|
||||
|
||||
|
||||
@Resource
|
||||
InvSubWarehouseDao invSubWarehouseDao;
|
||||
|
||||
@Override
|
||||
public List<InvSubWarehouseEntity> filterInvSubWarehouse(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest) {
|
||||
if (filterInvSubWarehouseRequest == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (filterInvSubWarehouseRequest.getPage() != null) {
|
||||
int offset = (filterInvSubWarehouseRequest.getPage() - 1) * filterInvSubWarehouseRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, filterInvSubWarehouseRequest.getLimit());
|
||||
}
|
||||
List<InvSubWarehouseEntity> data = invSubWarehouseDao.filterInvSubWarehouse(filterInvSubWarehouseRequest);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvSubWarehouseEntity> filterGroupInvSub(FilterInvWarehouseRequest filterInvWarehouseRequest) {
|
||||
if (filterInvWarehouseRequest == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (filterInvWarehouseRequest.getPage() != null) {
|
||||
int offset = (filterInvWarehouseRequest.getPage() - 1) * filterInvWarehouseRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, filterInvWarehouseRequest.getLimit());
|
||||
}
|
||||
List<InvSubWarehouseEntity> data = invSubWarehouseDao.filterGroupInvSub(filterInvWarehouseRequest);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvSubWarehouseEntity selectMaxCode(FilterInvSubWarehouseRequest filterInvSubWarehouseRequest) {
|
||||
return invSubWarehouseDao.selectMaxCode(filterInvSubWarehouseRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvSubWarehouseEntity> findByParentId(String code) {
|
||||
FilterInvSubWarehouseRequest filterInvSubWarehouseRequest = new FilterInvSubWarehouseRequest();
|
||||
filterInvSubWarehouseRequest.setParentId(code);
|
||||
List<InvSubWarehouseEntity> invSubWarehouseEntities = invSubWarehouseDao.filterInvSubWarehouse(filterInvSubWarehouseRequest);
|
||||
return invSubWarehouseEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvSubWarehouseEntity findByInvSubByCode(String code) {
|
||||
FilterInvSubWarehouseRequest filterInvSubWarehouseRequest = new FilterInvSubWarehouseRequest();
|
||||
filterInvSubWarehouseRequest.setCode(code);
|
||||
List<InvSubWarehouseEntity> invSubWarehouseEntities = invSubWarehouseDao.filterInvSubWarehouse(filterInvSubWarehouseRequest);
|
||||
if (CollUtil.isNotEmpty(invSubWarehouseEntities)) {
|
||||
return invSubWarehouseEntities.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity) {
|
||||
return invSubWarehouseDao.insertInvSubWarehouse(invSubWarehouseEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity) {
|
||||
return invSubWarehouseDao.updateInvSubWarehouse(invSubWarehouseEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
return invSubWarehouseDao.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
<?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.glxp.api.admin.dao.inventory.InvSubWarehouseDao">
|
||||
|
||||
<select id="filterInvSubWarehouse" parameterType="com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest"
|
||||
resultType="com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity">
|
||||
select *
|
||||
FROM inv_warehouse_sub a
|
||||
<where>
|
||||
<if test="id != '' and id != null">
|
||||
AND a.id = #{id}
|
||||
</if>
|
||||
<if test="code != '' and code != null">
|
||||
AND a.code = #{code}
|
||||
</if>
|
||||
<if test="name != '' and name != null">
|
||||
AND a.name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="parentId != '' and parentId != null">
|
||||
AND a.parentId = #{parentId}
|
||||
</if>
|
||||
<if test="defaultInv != '' and defaultInv != null">
|
||||
AND a.defaultInv = #{defaultInv}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="filterGroupInvSub" parameterType="com.glxp.api.admin.req.inventory.FilterInvWarehouseRequest"
|
||||
resultType="com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity">
|
||||
select inv_warehouse_sub.* from inv_warehouse_sub INNER JOIN inv_warehouse
|
||||
on inv_warehouse_sub.parentId = inv_warehouse.code
|
||||
INNER JOIN inv_warehouse_user on inv_warehouse_sub.code = inv_warehouse_user.code
|
||||
<where>
|
||||
<if test="userId != '' and userId != null">
|
||||
AND inv_warehouse_user.userId = #{userId}
|
||||
</if>
|
||||
<if test="pcode != '' and pcode != null">
|
||||
AND inv_warehouse.code = #{pcode}
|
||||
</if>
|
||||
</where>
|
||||
group by inv_warehouse_sub.id
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectMaxCode" parameterType="com.glxp.api.admin.req.inventory.FilterInvSubWarehouseRequest"
|
||||
resultType="com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity">
|
||||
select max(code) as code from inv_warehouse_sub
|
||||
<where>
|
||||
<if test="id != '' and id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="code != '' and code != null">
|
||||
AND code = #{code}
|
||||
</if>
|
||||
<if test="name != '' and name != null">
|
||||
AND name = #{name}
|
||||
</if>
|
||||
<if test="parentId != '' and parentId != null">
|
||||
AND parentId = #{parentId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertInvSubWarehouse" keyProperty="id"
|
||||
parameterType="com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity">
|
||||
replace
|
||||
INTO inv_warehouse_sub
|
||||
(id, code, `name`, parentId, remark,defaultInv)
|
||||
values (
|
||||
#{id},
|
||||
#{code},
|
||||
#{name},
|
||||
#{parentId},
|
||||
#{remark},
|
||||
#{defaultInv}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
<delete id="deleteById" parameterType="Map">
|
||||
DELETE
|
||||
FROM inv_warehouse_sub
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateInvSubWarehouse" parameterType="com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity">
|
||||
UPDATE inv_warehouse_sub
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="name != null">name=#{name},</if>
|
||||
<if test="code != null">code=#{code},</if>
|
||||
<if test="parentId != null">parentId=#{parentId},</if>
|
||||
<if test="remark != null">remark=#{remark},</if>
|
||||
<if test="defaultInv != null">defaultInv=#{defaultInv},</if>
|
||||
</trim>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="importInvSubWarehouse" parameterType="java.util.List">
|
||||
replace into inv_warehouse_sub
|
||||
(id, code, `name`, parentId, remark,defaultInv)
|
||||
values
|
||||
<foreach collection="invWarehouseEntities" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.code},
|
||||
#{item.name},
|
||||
#{item.parentId},
|
||||
#{item.remark},#{item.defaultInv})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue