切换分支本地暂时提交
parent
a4c372863b
commit
20d6b4a5e7
@ -0,0 +1,122 @@
|
|||||||
|
package com.glxp.sale.admin.controller.inventory;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.glxp.sale.admin.annotation.AuthRuleAnnotation;
|
||||||
|
import com.glxp.sale.admin.entity.inout.WarehouseBussinessTypeEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvSubWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.req.info.DeleteRequest;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest;
|
||||||
|
import com.glxp.sale.admin.res.inventory.InvWarehouseResponse;
|
||||||
|
import com.glxp.sale.admin.service.inventory.InvSubWarehouseService;
|
||||||
|
import com.glxp.sale.admin.service.inventory.InvWarehouseService;
|
||||||
|
import com.glxp.sale.common.enums.ResultEnum;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
import com.glxp.sale.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.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class InvSubWarehouseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
InvSubWarehouseService invSubWarehouseService;
|
||||||
|
@Resource
|
||||||
|
InvWarehouseService invWarehouseService;
|
||||||
|
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
|
||||||
|
// if (StrUtil.isEmpty(filterInvWarehouseRequest.getPcode()) || filterInvWarehouseRequest.getUserId() == null) {
|
||||||
|
// return ResultVOUtils.error(500, "用户或仓库不能未空!");
|
||||||
|
// }
|
||||||
|
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() == 0) {
|
||||||
|
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,29 @@
|
|||||||
|
package com.glxp.sale.admin.dao.inventory;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvSubWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||||
|
import com.glxp.sale.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.sale.admin.entity.inventory;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InvSubWarehouseEntity {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String code;
|
||||||
|
private String name;
|
||||||
|
private String parentId;
|
||||||
|
private String remark;
|
||||||
|
private boolean defaultInv;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.glxp.sale.admin.req.inventory;
|
||||||
|
|
||||||
|
import com.glxp.sale.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,26 @@
|
|||||||
|
package com.glxp.sale.admin.service.inventory;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvSubWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||||
|
import com.glxp.sale.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);
|
||||||
|
|
||||||
|
boolean insertInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||||
|
|
||||||
|
boolean updateInvSubWarehouse(InvSubWarehouseEntity invSubWarehouseEntity);
|
||||||
|
|
||||||
|
|
||||||
|
boolean deleteById(String id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.glxp.sale.admin.service.inventory.impl;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.glxp.sale.admin.dao.inventory.InvSubWarehouseDao;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvSubWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.entity.inventory.InvWarehouseEntity;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvSubWarehouseRequest;
|
||||||
|
import com.glxp.sale.admin.req.inventory.FilterInvWarehouseRequest;
|
||||||
|
import com.glxp.sale.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 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.sale.admin.dao.inventory.InvSubWarehouseDao">
|
||||||
|
|
||||||
|
<select id="filterInvSubWarehouse" parameterType="com.glxp.sale.admin.req.inventory.FilterInvSubWarehouseRequest"
|
||||||
|
resultType="com.glxp.sale.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.sale.admin.req.inventory.FilterInvWarehouseRequest"
|
||||||
|
resultType="com.glxp.sale.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.sale.admin.req.inventory.FilterInvSubWarehouseRequest"
|
||||||
|
resultType="com.glxp.sale.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.sale.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.sale.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